Quick Mail 1.3.0 Supports International Mail

Discover the latest version of Quick Mail.

Quick Mail WordPress Plugin

Quick Mail is a WordPress plugin that sends an email with an attachment from the WordPress dashboard.

Quick Mail sends email to a site’s members or to anyone. If the recipient is a WordPress user, their email address is copied from their profile.

Typos are common, so Quick Mail tried to validate the recipient’s domain, if a user entered an email address manually.

It was harder than I thought.

Validating Email Addresses

Quick Mail can validate email addresses with ASCII characters: specifically numbers, hyphens, and English letters.

I used PHP’s filter_var function to validate email addresses. WordPress includes is_email, a similar function.

Unfortunately, neither function handles international email addresses with non-ASCII characters.

Validating Email Domains

If I send an email to an invalid domain with my phone, I will receive a notification in a few seconds or minutes, that my email could not be sent, with a descriptive error message.

However, Quick Mail uses wp_mail, the WordPress mail function to send mail. WordPress says:

A true return value does not automatically mean that the user received the email successfully. It just only means that the method used was able to process the request without any errors.

It seemed to reasonable to test the recipient domain, before sending email. I used checkdnsrr to learn if the recipient’s domain had an MX Record. An MX record tells senders how to send email to a domain.

If a user tried to send email to a domain without an MX record, Quick Mail displayed an “Invalid Email Address” error.

That was wrong for international domain names, with non-ASCII characters.

WordPress removed this feature from is_email, six years ago.

Learning Punycode

Punycode was created in 2003.

Punycode is a simple and efficient transfer encoding syntax designed for use with Internationalized Domain Names in Applications (IDNA). It uniquely and reversibly transforms a Unicode string into an ASCII string.

For example, “mérens.club” = “xn--mrens-bsa.club” in Punycode.

PHP includes idn_to_ascii. I installed PHP Internationalization Functions on a test server, but it caused segmentation fault errors.

It is possible that my module was the wrong version. However, I could not fix it. Additionally, I do not expect WordPress users to install PHP extensions to use Quick Mail.

I tested Quick Mail on a different server, with idn_to_ascii and an international email address.

I might include PHP Punycode or PHP IDN Punycode in a future version of Quick Mail.

Quick Mail Validation Option

Quick Mail validation option Domain validation is an option in Quick Mail 1.3.0. Use it if your recipients have ASCII email addresses.

I looked at other email address validators, including is_email, but they were also limited to ASCII addresses.

How Does It Work?

Your Web browser checks for basic email address syntax, because the Quick Mail uses an email input for addresses. The W3C specifies that browsers should check inputs for this regular expression:

/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/

Quick Mail 1.3.0 simply checks for an amphora ('@') and a period, that are not at the beginning or the end of the address. You should know what you are entering. wp_mail also validates the address, before sending mail.

If the recipient’s domain name is in ASCII characters, Quick Mail checks the mail exchanger record on recipient domains, before sending a message. The mail exchanger record or MX, specifies the mail server that accepts messages for a domain.

Send an email to “name@example.com” to test Quick Mail domain validation.

wp_mail Errors

wp_mail Message

WordPress 4.4 added a helpful hook to wp_mail, for programmers.

wp_mail_failed lets you know why wp_mail did not send a message. I only saw one message while testing Quick Mail.

You must provide at least one recipient email address

This is displayed when the recipient’s email address contains non-ASCII characters.

You should only see this if:

  1. You entered a manual email address.
  2. Validate address is off.
  3. Your address passed a simple check for amphora and period.
  4. Your version of PHP does not include idn_to_ascii. wp_mail checks for it.

Other International Domain Name Errors

domain name tests

I removed two WordPress functions from Quick Mail: is_email and sanitize_email.

The image above this text, shows results of tests with two WordPress function: is_email and sanitize_email.

test@mérens.club is a valid email address. But is_email rejected it, and sanitize_email changed it.

PHPMailer Errors

wp_mail uses PHPMailer to send mail.

PHPMailer also has problems sending email to international domains. See IDN E-mail with username in Unicode is not accepted for more information.

Quick Mail 1.3.0 Requires WordPress 4.4+

WordPress 4.4 is required to see wp_mail errors.

quick_mail_version filter was removed

Quick Mail 1.2.2 added dismissible notices for status messages. Messages remain visible until the “Close” button is clicked.

Dismissible messages were added in WordPress 4.2. Nevertheless, Quick Mail could be used on WordPress 2.9, except dismissible boxes lacked a close button.

I added a WordPress filter on a whim, to Quick Mail 1.2.3 that reduces the minimum version.

I removed this filter, because WordPress 4.4 is required for wp_mail_failed to display a mail error. Mail errors are more important than dismissible boxes.

Get Quick Mail

Download Quick Mail 1.3.0 from the WordPress Plugin Repository. Fork Quick Mail on GitHub to add new features.

Quick Mail 1.3.0 was tested with WordPress 4.5.2.

I hope Quick Mail increases your productivity. Please leave a review to help others find it.

Thanks to everyone who has been translating Quick Mail. If Quick Mail helps you send email to international domains, please join the translation project so more people can use it.

Check out my previous articles on Quick Mail for more information.