Jump to content

BCC not sending to Gmail


Panta

Recommended Posts

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

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

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

"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

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...