Panta Posted September 29, 2014 Share Posted September 29, 2014 please i have been working on a code that will help me send bulk mail to me subscribers, i tried to use BCC but i notice that it works for yahoomail, but does not work for gmail, it sends only to yahoomails in the list and will not send to gmail, please these are my codes i need help <?php error_reporting(0); if (isset($_POST['formType'])) { if ($_POST['formType'] === "join_us") { // read the list of emails from the file. $email_list = file("elist.txt"); // count how many emails there are. $total_emails = count($email_list); // go through the list and trim off the newline character. for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } // implode the list into a single variable, put commas in, apply as $to value. $to = ""; // how to send an email with BCC $headers = 'MIME-Version: 1.0' . "r "; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "r "; // this email may not exist $headers .= 'To: Website <noreply@website.com>' . "r "; // this is a good email, that must exist (some user may send a reply) $headers .= 'From: Website <goodExistingEmail@website.com>' . "r "; // mails to be delivered to $headers .= 'BCC: ' . implode(', ',$email_list) . "rn "; $subject = "My email test."; $message = "Hello morrissing, how are you today bro?"; if ( mail($to,$subject,$message, $headers) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } } } ?> Link to comment Share on other sites More sharing options...
niche Posted September 29, 2014 Share Posted September 29, 2014 What errors do you get when you comment-out error reporting? Link to comment Share on other sites More sharing options...
Panta Posted September 29, 2014 Author Share Posted September 29, 2014 What errors do you get when you comment-out error reporting? i dont have error but the problem is that on this line $headers .= 'BCC: ' . implode(', ',$email_list) . "rn"; the emails i have in the $email_list only yahoomails do send but i will not see any in the gmail that i also have listed in $email_list. thank you Link to comment Share on other sites More sharing options...
niche Posted September 29, 2014 Share Posted September 29, 2014 What do you actually get when you echo $headers when there's a gmail address? Link to comment Share on other sites More sharing options...
Ingolme Posted September 29, 2014 Share Posted September 29, 2014 "rn r preceded by two slashes rather than one. That will probably cause a problem. Link to comment Share on other sites More sharing options...
Panta Posted September 30, 2014 Author Share Posted September 30, 2014 What do you actually get when you echo $headers when there's a gmail address? when i try to echo it nothing comes up, but yahoomails i have in the list do deliver just gmails that does not Link to comment Share on other sites More sharing options...
Panta Posted September 30, 2014 Author Share Posted September 30, 2014 "rn r preceded by two slashes rather than one. That will probably cause a problem. i tried to use the single one now but still cant send to gmail Link to comment Share on other sites More sharing options...
justsomeguy Posted September 30, 2014 Share Posted September 30, 2014 Every one of your header lines needs to end with rn. You have "r" in some places, and "rn", they all need to be "rn", and remove the extra line breaks. When you print headers you should see a list of the headers, one header per line, with no empty lines between them. Link to comment Share on other sites More sharing options...
Panta Posted September 30, 2014 Author Share Posted September 30, 2014 Every one of your header lines needs to end with rn. You have "r" in some places, and "rn", they all need to be "rn", and remove the extra line breaks. When you print headers you should see a list of the headers, one header per line, with no empty lines between them. $headers .= 'BCC: ' . implode(', ',$email_list) . "rn"; i have done that but at this line this is how i handled it, is it correct Link to comment Share on other sites More sharing options...
thescientist Posted September 30, 2014 Share Posted September 30, 2014 did you change every occurrence like JSG recommended? It's not enough to change that one, you have fix all of them. Link to comment Share on other sites More sharing options...
Panta Posted September 30, 2014 Author Share Posted September 30, 2014 did you change every occurrence like JSG recommended? It's not enough to change that one, you have fix all of them. please i dont know what you mean by JSG break it down for me please Link to comment Share on other sites More sharing options...
justsomeguy Posted September 30, 2014 Share Posted September 30, 2014 You also need to remove the line break at the end of the lines. The ending quote should be right after the n, not on another line. If you are in doubt, then print your $headers variable to see what it contains. Link to comment Share on other sites More sharing options...
thescientist Posted October 1, 2014 Share Posted October 1, 2014 please i dont know what you mean by JSG break it down for me please The user that replied to you is named justsomeguy (JSG). I was asking if you followed his instructions to fix all your instances of using newline. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now