Use php mass mailer or simply mail()?

2019-02-27 09:25发布

问题:

I am sending out ~30k email messages.

Each message will have slightly different content.

I have read that using the php mail() function is not a good idea for Mass Mailing.

What are the pro's and con's of using the inbuilt mail() function and the pro's and con's of using a Mass Mailer such as Swiftmailer.

With particular focus on the fact that it is not sending the exact same message to 30k addresses,

Instead it is sending slightly personalized messages.

回答1:

Outsource it or spend a lot of time with a library. SwiftMailer is a a good choice if you decide to go with a library.

Don't loop with a mail() :)



回答2:

Here is the canonical Stack Overflow response to this question (in this case to a potential spammer, hence the downvotes, but the information in the first answer is spot on)

How to send 100,000 emails weekly?



回答3:

firstly, people who say php mail() is a bad idea don't really know how to use it correctly, With php mail, it gives the developer the opportunity to send extremely basic messages with lack of concrete headers.

if you look at the PHP Documentation for mail()

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

The 4th and the 5th parameters allow you to supply header and additional information, these are what you should be looking into to get decent emails sent from php's Mail function.

The reason a lot of mail is never successful is because the recipient's mail system is blocking the email as spam or malformed because the headers aren't correctly build or lack important headers.

my advice would be to take a look at this OpenSource application called OpenCart, if you download the application and extract the library called Mail.. you can use this to send mail, it supports SMTP And PHPMail, But also takes care of headers so the the message is legitimate email and should not trigger a spam filter.

An example of who marks mail as spam if the headers is myself, as we run an Exchange 2010 server any mail that comes in without a Content-ID header is automatically marked as span.

As i stated at the top, there's nothing wrong with PHP mail, its just the developer overlooking important facts.

You can take a look at the class directly from here, if you look out for the line that highlighted you will see what I mean.

http://pastebin.com/nJi8Ms4Y6