If you're having trouble sending emails from your PHP script or application, it could be due to the way your application is configured to send emails. By default, many PHP applications use a protocol called PHPMail(), which can lead to several issues, including emails being marked as spam. This guide will help you understand why this happens and how to resolve it.

Understanding PHPMail()

PHPMail() is a function used by PHP to send emails directly from a server. However, it has a number of disadvantages and is often the reason why emails end up in the recipient's spam folder.

When an email is sent from a PHP application using PHPMail(), it uses an email address similar to youruser@your.servername.com. However, your application's configuration might be set to send emails from a different, more user-friendly email address, such as you@yourdomain.com.

This discrepancy can be recognized as 'spoofing' by many recipient mailboxes, which may flag the message as spam. Due to these issues, PHPMail() is disabled on our servers by default.

Using SMTP Instead of PHPMail()

We recommend using SMTP (Simple Mail Transfer Protocol) to relay all messages from your PHP script or application. SMTP is a protocol for sending emails reliably and efficiently.

SMTP uses proper authentication, which increases the chances of your emails being successfully delivered to the recipient's inbox. It also allows you to send emails from a user-friendly email address without being flagged as spam.

How to Configure Your Application to Use SMTP

The process of configuring your application to use SMTP instead of PHPMail() will depend on the specific application you're using. Many applications have settings or plugins that allow you to easily switch to SMTP. You'll typically need to provide the SMTP server name, port, and authentication details.

By understanding the cause of your email sending issues and switching to SMTP, you can improve your email deliverability and reduce the likelihood of your messages being incorrectly marked as spam.