My application sends emails to an Admin and to Customers upon payment is received.
I would like to add a BCC field for a backup email and do not want it to show.
I tried adding it as a BCC field but it is still showing when the email is received. The header reads as follows:
to me, bcc: the BCC e-mail, bcc: second BCC email
My code is as follows:
$to="email#hotmail.com";
$subject= "New order";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <email#gmail.com>' . "\r\n";
$headers .= "CC:".PHP_EOL;
$headers .= "BCC: email#hotmail.com, email2#hotmail.com".PHP_EOL;
mail($to, $subject, $msg2, $headers);
mail($email, 'Payment Confirmation', $msg2customer, $headers);
I tried removing the CC field, still the same result.
*Note: When the emails are received by a #hotmail.com account the BCC are hidden, but when received by a #Gmail.com account the BCC are shown. I'm on local host, did not try on a live server.
Thank you
Related
i am having a issue with sending emails with cronjobs.
actually i need to send email to all the recently joined users
and so the emails are something like $to='acx1#xyz.com,acx2#xyz.com,acx3#xyz.com';
here i need to send the mail to all the receipts but not to let them know that i have sent this mail to all these persons in receipt basically BCC them
but the problem is that if i put the $to into BCC then what should i put in to function of mail
if to is empty then it may be spamed
i want to send this mail to all the receipts but when they check the headers they should see their email only
and one more issue please let me know if i am using correct headers ?
because sometimes my email is spammed by gmail
$from='tests.com';
$to='contact#test.com';
$message="<body> some html data with inline css </body>"
$subject="Hii this is test";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$headers .= "From: $from <contact#test.com>" . "\r\n";
$headers .= "Reply-To: contact#test.com" . "\r\n";
$headers .= 'BCC: acx1#xyz.com,acx2#xyz.com,acx3#xyz.com' . "\r\n";
mail($to, $subject, $message, $headers);
I am sending email using mail() The problem is I am not getting an email to a specific email id if the recipient id does not exists, I have tried the following code.
$email="abcdt01est#gmail.com";
$usermsg="some message here";
$subject = 'Your Account Registration Confirmation';
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: Our Team <team#test.com>" . "\r\n";
$headers.="Return-Path:<my email id goes here>\r\n";
mail($email, $subject, $usermsg, $headers);
I have also tried with
mail("abcdt01est#gmail.com", "subject", "body of message", "From: team#test.com", "-f<my email id>");
Mail function in PHP mail() only informs about E-Mail has been accepted by the outgoing server, and plays no role in checking E-Mail's actual delivery status.
You can check your mail log /var/log/mail.log if sendmail is configured properly.
Visit this http://www.phpclasses.org/package/9-PHP-PHP-mailer-to-compose-and-send-MIME-messages.html - MIME E-mail message sending: PHP mailer to compose and send MIME messages.
I have a php form that I made and when someone fills out the form it works fine with all other email accounts (yahoo, hotmail, #mydomain.com, etc) but when it comes to sending the email to a gmail user, the email never comes through, not even in the spam box.
$from = $email;
//Testing Below
//$headers = 'From:noreply#mydomainname.com' . "\r\n";
$headers .= "From: $from \n";
$headers .= " MIME-Version: 1.0\r\n ";
$headers .= " Content-Type: text/html; charset=ISO-8859-1\r\n ";
//Mail The Message
mail($to, $subject, $message, $headers);
The code above will not send to gmail but will work for all other email accounts. This one (below) will work for gmail but of course then I don't have the option of html in the email.
$headers = 'From:noreply#mydomainname.com' . "\r\n";
//$headers .= "From: $from \n";
//$headers .= " MIME-Version: 1.0\r\n ";
//$headers .= " Content-Type: text/html; charset=ISO-8859-1\r\n ";
//Mail The Message
mail($to, $subject, $message, $headers);
So basically when I add the MIME and Content type to the headers variable it wont send to a gmail account.
Thanks in advance!
I have replied a question not too long ago related to this. It might have to do with the gmail's email filtering, maybe you are getting too high spam score so it's not even getting into the spam folder, this could be caused by not having correct dns configuration / keys and trying to use html at the same time.
I leave a link to the other answer (It's quite long, and not as easy as you would imagine xD):
PHP and Gmail spam filter
Hope it helps you.
You are not using a proper concatenation operator:
Change your From line to:
$headers .= "From: ".$from;
I am tring to sent email to multiplw users in Bcc through PHP mail scriptcode is as follows -
$recipients =array('recpient1#gmail.com','recpient2go#gmail.com');
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$to = '';
$subject = "E-mail subject";
$body = "E-mail body";
$headers = 'From: info#mydomain.com' . "\r\n" ;
$headers .= 'Reply-To: info#mydomain.com' . "\r\n";
$headers .= 'BCC: ' . implode(', ', $recipients) . "\r\n";
$email =mail($to, $subject, $body, $headers);
if we leave $to black then user in gmail detail shows "to undisclosed recipients" and Bcc not shows how can be show "Bcc me (user who got mail)" i search a lot, but didn't got any proper answer
BCC stands for Blind Carbon Copy and its main purpose is, that you can not see the other recipients of that mail.
If you want to show all email addresses use CC (Carbon Copy) instead.
Be aware, though, that all recipients now can see all other recipients' email addresses, which increases the probabilities having those email addresses end up in spam catalogs.
You can't control how the people at Gmail decide to display the recipients list when reading an email. Each webmail system decides how they want to display the recipients list.
Maybe you can fin another webmail system that decided to display "Sent to me#my-email" instead of "Undisclosed recipients"...but why does it matter to you?
Why do you care about that? I'd say it is a false problem. Since you received the email, it was of course sent to you.
My website runs the following code: (I BCC myself so that I have a copy of all the emails that my website sends out)
//prepare email headers
$headers = "From: " . "info#mysite.com" . "\r\n";
$headers .= "Reply-To: ". "info#mysite.com" . "\r\n";
$headers .= 'Bcc: sent#mysite.com' . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = getMsg( ... );
mail( $buyer_email, 'mysite.com - Verify your information.', $message, $headers );
$message = getMsg( ... );
mail( $seller_email, 'mysite.com - Verify your information.', $message, $headers );
The emails get sent out perfectly fine. The problem is with the second email that gets BCC'ed to me. The recipient's email address is blank so I can't see who the email was sent to. The first email that's BCC'ed to me is fine, all the info shows up. In other words, I can see $buyer_email, but I can't see $seller_email. Any ideas?
You can debug it like this
echo "Seller Email: $seller_email";
mail( $seller_email, 'mysite.com - Verify your information.', $message, $headers )
The page will print the seller email and you can see what it actually is.
Addition
If you can not use the above code because you have to test it a user (which is normal btw), use the following technique.
Since you are getting the first email, send $seller_email as part of test code in that email and see what value it has.
$message = getMsg( ... );
mail( $buyer_email, "mysite.com - Test Seller Email: $seller_email .", $message, $headers );
You will find out the seller email value in the email you get.
Does sending additional headers help? (see mail()) That way you don't have to use 2 mail functions.
Like this:
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
I'm very sorry, but I made a huge mistake. Long story, but basically I was confusing code on one page with very similar code on a different page. I was testing the validity of $seller_email on the wrong page. On the page in question, it was in fact NOT being set. Once again, sorry. I should have posted the entire code.