Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending mass email using PHP

I am currently writing a music blog. The administrator posts a new article every 2-3 days. Once the administrator posts an article, a mass email will be sent to around 5000 subscribers immediately.

What is the best way to implement the mass mail feature?

Does the following function work?

function massmail()  {   $content = '...';   foreach ($recipients as $r) {     $_content = $content . '<img src="http://xxx/trackOpenRate.php?id='.$r.'">';     mail($r, 'subject', $_content);   } } 

Another question: If all 5000 subscribers are using Yahoo Mail, will Yahoo treat it as a DDOS attack and block the IP address of my SMTP server?

like image 994
Alan Avatar asked Jul 13 '09 07:07

Alan


People also ask

Can PHP be used to send emails?

PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient's email address, the subject of the the message and the actual message additionally there are other two optional parameters.

How to send email using PHP with PHPMailer and ajax jquery?

php'; $output = ''; foreach($_POST['email_data'] as $row) { $mail = new PHPMailer; $mail->IsSMTP(); //Sets Mailer to send message using SMTP $mail->Host = 'smtpout.secureserver.net'; //Sets the SMTP hosts of your Email hosting, this for Godaddy $mail->Port = '80'; //Sets the default SMTP server port $mail->SMTPAuth = ...


1 Answers

First off, using the mail() function that comes with PHP is not an optimal solution. It is easily marked as spammed, and you need to set up header to ensure that you are sending HTML emails correctly. As for whether the code snippet will work, it would, but I doubt you will get HTML code inside it correctly without specifying extra headers

I'll suggest you take a look at SwiftMailer, which has HTML support, support for different mime types and SMTP authentication (which is less likely to mark your mail as spam).

like image 136
Extrakun Avatar answered Sep 23 '22 11:09

Extrakun