Send Reliable Email from WordPress with Quick Mail
Tougher security requirements make it harder to send email from a Web site.
I had emails sent by Quick Mail, rejected by Gmail.
There was no indication from Quick Mail, that the message was not delivered. Google’s error message was buried in an email sent to the fictitious user running the Web server.
I needed to send secure emails ASAP.
I am not affiliated with Mailgun or Sendgrid, but I have used them on jobs.
The Sendgrid Email Delivery Service was more familiar, so I used it first. Sendgrid installed in minutes and worked perfectly.
Sendgrid is not free. I tested it using a free trial account.
Mailgun is also familar.
Mailgun is free, works perfectly, but takes longer to install. You must verify your domain to send mail, and wait for the DNS changes to propagate.
Quick Mail 3.2.1 also adds the ability to email the contents of a file or Webpage with the
quick-mail command for WP-CLI.
Using Quick Mail with Mailgun
Send authenticated emails with Quick Mail and the Mailgun API.
Take your time, following the instructions.
- Open an account.
- Verify your domain. Use the domain which will be sending email, for best results. It can take up to a day for your domain to be verified.
- Install Mailgun Plugin.
- From Mailgun Plugin Settings:
Use HTTP APIto “Yes.”
- Select “Test Configuration” to verify settings.
Override “From” Details
Mailgun plugin includes an option to replace the sender address.
This is confusing, if the sender is not the person who installed the plugin.
Quick Mail circumvents this option, if the user is not an administrator.
I asked Mailgun to allow users to disable this feature, but they have not replied.
Quick Mail will report a Mailgun error.
Avoid errors by selecting “Test Configuration” on the plugin settings page, before sending mail.
Using Quick Mail with Sendgrid
Sendgrid is not free.
However, it is the fastest way that I know to setup guaranteed email deliveries from any server — including localhost.
Audrey Capital, the investment branch of WordPress, invested in Sendgrid back in 2010. Sendgrid works perfectly with WordPress.
- Install the Sendgrid plugin.
- Send a test email from the plugin settings page to verify your settings.
- “Use Sendgrid credentials” was added to the Quick Mail settings, to replace your sender name and address.
- Only administrators can replace their sending credentials – same as Mailgun settings. Otherwise users would send mail with the administrator’s settings.
Replacing Quick Mail Sender
replace_quick_mail_sender filter, to use
Quick Mail with other services, or simply to change the sender’s name.
I did not add a setting to change your name, but I wrote a plugin to add this feature.
Download and install Replace Quick Mail Sender plugin from Github to try this.
Alternate Sending Choices
I tested and reviewed WP Mail SMTP last year. You can use this plugin to send mail from Gmail, Yahoo, Microsoft, etc. Unfortunately, this plugin was sold, and support questions are not answered by the new maintainer.
SMTP Mailer is similar, but supported.
Find additional plugins by searching for SMTP on WordPress plugin repository.
PepiPost offers a free API and delivery service.
Install the PepiPost plugin, to use it with WordPress.
Read Top 5 Best WordPress Email Plugins and Platforms for Better Deliverability for more choices.
Send a Web page or file with Quick Mail and WP-CLI.
I added a WP-CLI command to send a file or Web page from the command line.
wp quick-mail <from> <to> <url or file> [<subject>] [<message_attachment_file>]
The command line is long, but you can use this from a script or batch file.
If you are typing, you can replace sender and recipient email addresses with WordPress user Ids.
I started with URLs, to send the content of Web pages from the command line. Then I added files. Files are just a different type of content. The ability to send files makes the command more useful.
Sending Two Files
Did you ever expect to apply to a job from the command line?
Let’s say you wanted to email your resume (resume.doc) with a cover letter (cover.html).
wp quick-mail <from> <to> resume.doc Application cover.html
This sends a message with the subject “Application.” Message is the content of cover.html with resume.doc attached.
For Administrators Only
It seems prudent to limit access to administrators. The sender’s email address must belong to a WordPress administrator.
WP-CLI command line includes a
--user option, but I am not checking it.
Sending Web Pages with Quick Mail and WP-CLI
wp quick-mail <from> <to> <https://example.com/> [<subject>]
wp quick-mail works best for Web sites which have the full path of their stylesheets on their page. Images must be enabled on the recipient’s mail reader, to load external stylesheets and images.
Subject is optional. The title of the Web page will be used for the email, if a subject is not entered.
Notes on Sending Web Pages
- http / https
- Link must start with
https, to distinguish it from a file.
- Without WP-CLI
- Send any Web page, including an unpublished WordPress document, by copying and pasting its code into a “text” message.
Quick Mail will identify the content as HTML. The recipient will see a styled Web page — if their mail reader loads images / stylesheets.
Sending files with Quick Mail and WP-CLI
wp quick-mail <from> <to> <filename.txt> [<subject>]
Sending a file is like sending a Web page. An additional benefit is that the file can be generated dynamically by a script.
Linux: getting e-mail notification on user login by Samuele Santi, inspired me to write this feature.
Santi’s script uses Mutt, a text-based mailer, to email the output from a bunch of Linux commands, after a user logs in.
You can do the same thing with Quick Mail.
Sending Images / Binary Files
I use mime_content_type to check file content. If content is
text/html, the contents of the file are the message.
An image, or binary file like a .zip, is sent as an attachment with a generic message: “Please see attached file : filename.doc.”
However, I added yet-another option, to change this.
See the example for sending a resume and cover letter.
Default Subject for Files
For Your Eyes Only seemed appropriate.
Add your own subject, to change it.
What’s Next for Quick Mail?
I added Mailgun and Sendgrid, before I checked my previous list from Quick Mail 3.1.7.
Quick Mail has enough features. It should be easier to replace Sendgrid. I considered writing an example. I would rather make it easier, in the future.
Quick Mail might need one more option: to limit the number of comments that are loaded. Otherwise, there are too many options, and not enough documentation.
For example, there are six uses of apply_filters. They are now documented in readme.txt, but should probably be in a wiki.
Get Quick Mail 3.2.3 from WordPress or Github
Quick Mail 3.2.3 was tested with WordPress 4.9, including multisite.
I hope Quick Mail makes your life easier. Please leave a review to help others find it.