Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP send mail to 1 to 10 recepients
    primarykey
    data
    text
    <p>I am sure I am overlooking something here, all other mail scripts are working fine except this one. I have an HTML form which collects up to 10 email addresses. all I need to do it to iterate through them and if they are filled, send email to the recipient.</p> <pre><code>$email0 = 'email@email.com'; $email1 = 'some@email1.com'; $email2 = 'some@email2.com'; $email3 = 'some@email3.com'; $email4 = 'some@email4.com'; ....... up to 10. $i=1; while($i&lt;=10) { $temp = 'email'.$i; if(isset($$temp) &amp;&amp; $$temp != '') { $subject="some subject"; $body = "email content"; $headers = "From: $email0 \r\n"; $headers .= "Reply-To: $email0 \r\n"; mail($$temp, $subject, $body, $headers); } $i++; } </code></pre> <p><strong>...OK I just tried a different way. I stuffed all the emails in one array and iterated through it. The same result, no emails received!!!! What am I missing ? :)</strong></p> <pre><code>$recipients = array($email1,$email2,$email3,$email4,$email5,$email6,$email7,$email8,$email9,$email10); foreach($recipients as $value) { if($value != '') { $subject2="some subject"; $body2 = "some content"; $headers2 = "From: $email0 \r\n"; $headers2 .= "Reply-To: $email0 \r\n"; mail($value, $subject2, $body2, $headers2); } } </code></pre> <p><strong>At this point I am going to post the following:</strong></p> <ul> <li>It just so happened that all my previous attempts started to come into may spam box (several hours latter!). So my suspicion seems to be confirmed: when on GoDaddy shared hosting do not send more than one email at the same time in short intervals (with the same content) or it will end up labeled as spam!</li> </ul> <p><strong>SOLUTION:</strong></p> <p>As jmbertucci in the posts below suggested, the simplest solution is to use BCC: for all the recipients in one email. Since I had to personalize each email, I noticed that if I include the unique char. into the subject line for each email, it goes through with no problem as well. So my solution is adding the recipients' name into the subject line (which makes all emails unique) but any unique string should do the same (like date() etc.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload