I wrote a mailing script phpmailer/swiftmail supported. Actually small campaigns works fine, all mails arrive to receivers without spam or server resouce problems.
I have question about per connection sending performance. Which way better for sending action? (Subscriber specific different mail body)
First scenario;
$mail->SMTPKeepAlive = true; foreach($newArray as $k=>$v){ $mail->AddAddress($k, $v['name']); $mail->Subject = $v['subject']; $mail->Body = $v['content']; $mail->Send(); } $mail->smtpClose();
Second scenario (Current method on my script, I've call phpmailer class into record loop);
while($rs = $sql->fetch_assoc()){ Replace Newsletter Data/Header Call PhpMailer - Common SMTP Connection settings $mail->SMTPKeepAlive = true; $mail->AddAddress($rs['mail'], $rs['name']); $mail->Subject = $campRs['subject']; $mail->Body = $campRs['content']; $mail->Send(); } $mail->smtpClose();
I'm confused about that, if I go for large amount mailing list, any server or script problems may occur?
Best regards!
The vast majority of time spent sending an email is the SMTP communication between your web server and the SMTP server it is talking with.
Both scenarios are likely to be equivalently fast.
If you need to increase performance, look into having multiple threads sending to different email addresses concurrently.