We've recently modified our e-commerce web application and replaced the native PHP mail functionality with a Phpmailer and SMTP. It was a pretty straightforward change, and we kept the mail format to "Plain/Text" format and changed the mail host to "smtp.sendgrid.net". After the change, we've noticed that the newline "\n" wasn't interpreted correctly and the mail we received was all garbled up. After some investigation, we found 2 things that needed to be changed to correct the problem.

SMTP Email Address Validation

How do you validate an email address? You may validate it with a javascript on the client-side, or run a server-side validation via a regular expression or a newly available filter_var function of the PHP 5.2.x. Perhaps, you may want to go one step further and verify the email address from the remote SMTP server.

Setting mail header for a foreign language

In our interconnected world, effective communication extends beyond borders and languages. When it comes to email communication, it's essential to cater to diverse audiences, including those who communicate in foreign languages. One powerful way to enhance this experience is by setting appropriate mail headers for foreign languages. In this guide, we'll explore the importance of mail headers, the steps to set them for different languages, and best practices for seamless international communication.