The cart is empty

Sending Email Using the PHP mail() Function

The PHP mail() function is an extremely simple function in PHP for sending emails. The script might look something like this:

<?php
mail("This email address is being protected from spambots. You need JavaScript enabled to view it.", "Subject of the email", "Body of the email");
?>

First, it's important to note that viruses on infected websites use a very similar script!

As you can see, the script does not define the email header, does not set the encoding for the Czech language, and does not convert the subject to base64. The script simply sends the email in its most basic form. Many developers of e-shops, content management systems, and websites in general use this function in exactly this format.

What Are the Consequences of Using the mail() Function?

Nowadays, most mail servers require a properly formatted email with a defined email header, usually including an SPF record or DKIM. Most mail servers also block all emails sent using the mail() function, even if you have defined email headers. The email will not arrive in the inbox or, at best, will end up in the spam folder.

Several clients have contacted us, reporting that emails from Prestashop and other e-shops do not reach their clients' mailboxes. This was particularly an issue with delivering emails to Gmail, Yahoo, Livemail, etc. By checking Prestashop settings, we found that they were sending emails to clients using the mail() function. We changed their Prestashop settings to send emails via SMTP, and the problem was resolved.

On our hosting service, you can send emails using php mail(), SMTP, and sendmail without limits.

The Most Reliable Method of Sending Emails

The most reliable method of sending emails is still via SMTP. If you want to increase the success rate of email delivery, set the following SPF record for your domain for MyDreams servers:

v=spf1 a mx +ip4:178.238.41.64/26 +ip4:85.118.130.64/26 +ip4:83.167.253.128/25 +ip4:149.62.151.128/26 +ip4:46.19.36.211 ~all

If setting the SPF record does not help, it is necessary to implement DKIM.