Sending mail to a large number of people

I read a lot of questions and answers about this issue in StackOverflow, but none of those that I read answered my question specifically.

I do not want to have a mailing list. People mark the box if they want to receive bulk email. There are no invalid emails because accounts are activated via email. So no bounce check. However, I already use PHPMailer (so there is no problem with headers, etc.) and add each address in the "in" field of the email message. This means that everyone can view all emails (by reading the source of the email or by striking a “reply to everything” in their email client), which is undesirable for other users. The question arises:

1), should I send all letters separately or put all addresses in the "Bond" field? 2) Doesn’t this make some mail servers mark this message as “spam”, no matter how well structured it is? If so, is there a way to prevent this (in addition to adding an address to any whitelists or setting domain keys or jobs to work on Unix)?

Thanks!

All of the requirements listed here require the user to "sign up" using the form, and then confirm their email address (for example, in PHPList). However, I already ask for confirmation when people register, so it makes no sense to ask them again and again. My existing code validates the database; if the "receive-movie-mail" bit is set to 1 (they are collected using an SQL query), an email is sent to them when a new movie is added to the database. So, if you still think that this is a mailing list (which, in my opinion, seems to be, but maybe my definition does not match the existing functions of the software), I would like it to have: 1) some way of subscribing users to the list with the PHP code (EG, if the checkbox “I want to receive an email every time I upload a movie to the database” is checked, I signed them in my form processing code) and 2) a way to send people with PHP (IE - send_mail_to_list function ( $ content), which sends an email to the people I signed up when ulation form "Add Movie"). Is there any mailing list management software?

+6
source share
5 answers

You should loop around the list of letters and send an individual email for each address:

$mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "mail.{domain_name}.com"; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "{username}"; // SMTP username $mail->Password = "{password}"; // SMTP password $emailFrom = '{email_address}'; $mail->From = $emailFrom; $mail->IsHTML(true); // set email format to HTML if needed $emailSubject = '{your subject}'; $emailBody = "Whatever content you are sending."; $mail->Subject = $emailSubject; $mail->Body = $emailBody; foreach($emails => $email) { $emailTo = $email['email']; $emailToName = $email['name']; // send an email to customer $mail->AddAddress($emailTo, $emailToName); if(!$mail->Send()) { echo 'failed'; } $mail->ClearAddresses(); } 
+3
source

1) Do I have to send each email individually or put all the addresses in the "bcc" field?

Definitely individually. Bcc will be displayed as spam.

2) Could this be the reason that some mail servers will mark e-mail as "spam", but how well is it structured? If so, is there a way to further prevent this (besides adding an address to some whitelists or setting up domain keys or Unix cron jobs)?

using an SPF record may help. Make sure that the reverse dns to your server is not blacklisted, especially if it is shared hosting.

+1
source

I did not do this in php since I know that by default there are no hyperthreads in php.

In other languages ​​/ frameworks such as Ruby or .NET, you send separate emails together via hyper / multithreading. This is similar to the * nix cron jobs approach you are aware of, except that it runs at runtime - you create one thread for every 5 addresses you send, and then all threads send 5 letters one by one.

Keep in mind that even with this approach, the neck of the bottle shifts from the application to the mail server you are using. So let's say that you are using the built-in postgre that comes with apache - it will not handle large volumes, since each thread will add load to it.

And of course you should avoid this together if you can use MailChimp !!

0
source

Send each user a separate letter addressed only to them.

Configure DKIM and SPF , or at least create appropriate SPF records. DKIM requires some configuration of the mail server, which actually sends you mail, but can significantly help ensure accessibility, especially for large email providers.

0
source

My advice next to others will be: to maintain a queue of letters where you can limit the speed of delivery. Some email providers do not like it when you try to send thousands of emails to your domain at the same time.

This should be possible with some MTAs. But I have not seen one that is flexible enough to do this. To do this, I used the Pear Mail_Queue class + cron job.

0
source

Source: https://habr.com/ru/post/894943/


All Articles