PHP Mail() vrs SMTP Pros and Cons

General topics that do not belong in other sections
Post Reply
User avatar
admindave


Site Admin
Posts: 11
Joined: Mon Feb 26, 2024 12:11 pm
United States of America

PHP Mail() vrs SMTP Pros and Cons

Post by admindave »

SMTP vs PHP mail(): Which One Should I Use?
Often a PHP application that sends mail will do so using the PHP mail() function and without needing SMTP credentials. Using PHP mail() function invokes a Sendmail program. PHP mail has its own unique advantages in certain niche scenarios. However, it is not recommended to use with applications such as
such as WordPress and other open source projects. There are several reasons for this.

Let’s take a look at some Pros and Cons of each option:

PHP mail() Pros:
1. It’s integrated into a lot of applications out of the box.
2. Because it’s been in use on Linux for so long, it’s also connected to the default MTA (if installed), making configuration relatively easy.

PHP mail() Cons:
1. Sending mail via PHP mail() means the messages dispatched will not benefit from the SPF and DKIM setup on your domain and so the messages could likely be treated as spam by the receiving MTA (mail server).
2. If you are not on a VPS, the per hour limits for sending mail messages are very restrictive. If you are sending out a newsletter this means it could take youi a long time to get this completed.
3. Guarenteed deliverability of messages is not possible.
4. When there is a failure due to bounceback, you wont receive notification of any kind.


SMTP Pros:
1. SMTP offers a proven technology for sending email which can be sent securily using encryption methods.
2. The risk of considered spam is extremely reduced.
3. Security features are available such as DKIM and SPF signatures.
4. The ability to authenticate (handshake) with the receiving mail server to verify the domain origin of the message.

SMTP Cons:
1. Since it is not native (in box) with most PHP applications like WordPress, it may require additional coding modifications or a WordPress plugin ti integrate it into your project.
2. If you use a PHP project such as PHPMailer then you wont have to develope your own mail server and SMTP protocalls. This makes using SMTP for the average site own very easy to intigrate into your project.
3. You will need to create additional user with strong password to use SMTP.

So in closing, as you can see using SMTP with your PHP application is the better choice.
If i can help you let me know :)
Post Reply