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.
Related
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
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'm using normal php mail() function to send emails. This works fine on localhost.
But in the online when i try to send a mail with images in the body with <img ../> tag the email won't go. Actually the mail function return true. Even though my inbox won't get any.
WHen I remove the <img> tags and try , emails are receiving to the inbox.
Please help
Thank you
$this->checkAuth();
//headers
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html; charset=iso-8859-1" . "\r\n";
$headers .= 'From: ' . $from . ' <' . $from . '>' . "\r\n";
$headers .= 'Reply-To: ' . $from . ' ' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($to, $subject, $message, $headers);
$this->_exit();
would be helpful if we could see your code but I'm gonna go out on a limb here and ask you to check your spam folder and make sure the image tags are formatted corectlly and that the email script contains no errors.
also here's a helpful link http://css-tricks.com/sending-nice-html-email-with-php/
Are you only sending a html mail?
Some mail scanners do not allow html only mail and need a plain text mail too, perhaps because you are sending an image it gets reported as spam.
This can block your mail from being send and as far as php is concerned it has been send.
Take a look at: http://kevinjmcmahon.net/articles/22/html-and-plain-text-multipart-email-/
Or the code:
//specify the email address you are sending to, and the email subject
$email = 'email#example.com';
$subject = 'Email Subject';
//create a boundary for the email. This
$boundary = uniqid('np');
//headers - specify your from email address and name here
//and specify the boundary for the email
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: Your Name \r\n";
$headers .= "To: ".$email."\r\n";
$headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";
//here is the content body
$message = "This is a MIME encoded message.";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/plain;charset=utf-8\r\n\r\n";
//Plain text body
$message .= "Hello,\nThis is a text email, the text/plain version.
\n\nRegards,\nYour Name";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/html;charset=utf-8\r\n\r\n";
//Html body
$message .= "
Hello,
This is a text email, the html version.
Regards,
Your Name";
$message .= "\r\n\r\n--" . $boundary . "--";
//invoke the PHP mail function
mail('', $subject, $message, $headers);
This sounds like the emails you send containing the image tags are sent to your spam mailbox.
Are you using some mail provider like gmail? They mostly throw untrusted messages directly into the spam folder. With untrusted I mean accounts which are freshly registered.
It's not something new that mails sent with PHP's native mail() function cause the messages to be detected as spam. It's the way php prepares the message headers.
So, using a php mail library like SwiftMailer is the way to go. It provides you with good customization options and contains functionality that'll make sending mails with attachments a lot easier.
Check it out: http://swiftmailer.org/docs/messages.html#attaching-files
Here's an example of how to use SwiftMailer for sending an email message with an image attachment:
<?php
require_once 'lib/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
->setUsername('your username')
->setPassword('your password');
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create the message
$message = Swift_Message::newInstance()
// Give the message a subject
->setSubject('Your subject')
// Set the From address with an associative array
->setFrom(array('john#doe.com' => 'John Doe'))
// Set the To addresses with an associative array
->setTo(array('receiver#domain.org', 'other#domain.org' => 'A name'))
// Give it a body
->setBody('Here is the message itself')
// And optionally an alternative body
->addPart('<q>Here is the message itself</q>', 'text/html');
// Add the attachment
$message->attach(Swift_Attachment::fromPath('/path/to/image.jpg'));
// Send the message
$result = $mailer->send($message);
Give it a try.
I have a strange issue with sending a mail with php, here is my code:
$link = "http://www.somelink/verify.php?id=".$uniqID;
$message ="<html><head></head><body><p>Full Name:".$data[0]." ".$data[1]."</p>";
$message .="<p>Flight Number: ".$data[4]."</p>";
$message .="<p>The Ride: ".$curPlace." to ".$data[5]."</p>";
$message .="<p>Number of Passengers: ".$data[3]."</p>";
$message .="<p>Date:".$data[6]." time:".$data[7]."</p>";
$message .="<p>The price: ".$data[8]."</p>";
$message .="<p>To verify the reservation press this link</p></body></html>";
$headers = 'From: my#email.com' . "\r\n" .'Reply-To: some#email.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "Sensitivity: Personal"."\r\n";
$sent=mail($data[2],"Taxi Reservation",$message, $headers);
if($sent){
echo "Message was sent to ".$data[2];
}
else{
echo "Message was not sent";
}
The problem is with Gmail.If I send it as is, I get the success message, but get nothing in my gmail, but do get in another not gmail account.
BUT!
If I delete a tag from this line:
$message .="<p>To verify the reservation press this link</p></body></html>";
I do get the message in Gmail.So I can't understand what's the problem.
What can couse this problem?
Thank you for your help.
If your email is not arriving at Gmail, but the same code sending the same email is arriving at a different account, I suspect that the problem is that Gmail are seeing your email and classifying it as spam - have you checked to see if it's gone into your spam folder instead of your inbox?
Gmail has a set of rules to identify what they think is spam - presumably, including the link is enough to push your email into the spam category.
i am using this code :
$to = "someone#example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse#example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
it sends email to my gmail's SPAM folder .
Suggest any solution .
i dont want to use any PEAR MAIL type way to send email or dont want to require and include any file.
This functions works without including/requiring any additional php file.
You should use proper header like this from PHP manual
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
The Gmail spam filter has lots of parts to it which determine the spamminess of mail. You could start by seeing the SPF record for your domain. Avoid using sales language, HTML and colours where possible in your email.
There's also an old but fun video from Google about how their spam filtering works.
It's all in the headers. I don't know how GMail works internally, but I've found on my projects that setting Reply-To can Content-Type headers seems to fix this.
See PHP mail() docs for an example of doing this.
(Note: I've got a PHP questionnaire/response system that sets these headers and the e-mails come through correctly to GMail, Hotmail and Yahoo! Mail).