I've created a form to get information from end users and email to a specific person. I'd like for the form to also be emailed to the submitter. Everything works, except when I try to Bcc the submitter. If I add the line to Bcc, the email is not sent. If I delete the line to Bcc the email is sent correctly, but the submitter doesn't have a copy of the email. Here is the code,
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: $email' . "\r\n";
$headers .= 'Bcc: $email_bcc' . "\r\n";
Add the BCC Receiver to the recipients but NOT to the headers!
Using Bcc in the header should be fine. However, make sure, that your mail server is not killing the mail because of it.1
Check the return value of the mail function. This should return false, if an error occured. If that is the case, you should send an extra mail to the sender.
Windows Server seem to have a problem with this.
Related
I have read that i must include some headers when using mail() function in PHP like:
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
but in my case i want only to send text, not html. so are those headers will still be required to make a successful mail?
Headers of mail() function are optional.
Your email can be delivered successfully, without any header.
Note that some default values will be set. As an example, if you do not declare a sender (From), the server name will be used instead.
I have a php mailing list in which, when someone sends an email to group email, it gets sent to all members of that group. So when James sends email to groupemail#tes.com, It gets sent to all members of group, i want members to be able to reply to James only by clicking "reply" in their email client or reply to group email by clicking "reply all" in their client. Please suggest how this can be done. IF i set group email in Cc header, the email gets sent to recipient twice, once from cc and once from reply-to. The code for header that I have right now is:
$headers = 'From: '. $senderName .' <'.$senderEmail.'>'."\r\n";
$headers .= 'Reply-To: '. $senderName .' <'.$senderEmail.'>'."\r\n";
$headers .= 'Cc: '.$groupTitle .' <'.$groupEmail.'>'."\r\n";
$headers .= 'X-Mailer: PHP' . phpversion() . "\r\n";
$headers .= 'MIME-Version: 1.0'."\r\n";
You can store reply all data in a array. In header portion of reply-to run a for loop to execute that data. Just formatting like single email address.
You can make your group distribution service the way it redirects messages so that one won't get the message from the group address if he is in the To-list. Unfortunately, this is how email clients work, so you can't change something anout it using the way you send mails.
How to hide server name when send email using php to gmail?
I test my code on hotmail it's not show server name , But when i test send mail to gmail why gmail show server name. How to remove it's
http://image.ohozaa.com/i/b2b/Jqx7Zg.png
$headers = 'From: NUMBERONE<admin#numberone.com>' . "\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
How can i do?
I think you will find that the hostname is still there in hotmail (view email header/source). Gmail just chooses to make it visible for anti-spam/fraud reasons.
If you have reverse DNS setup for a static IP dedicated to your webserver you could resolve this.
from address come with server extension, errror info#gmail.com via ecbiz132.hostername.com . how to solve this
$subject = "confirmation";
$from = "info#gmail.com";
$to = $email;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To:<'.$to.'>' . "\r\n";
$headers .= 'From: <'.$from.'>' . "\r\n";
$senad_replay = mail($to, $subject, $content, $headers, $from);
// errror info#gmail.com via ecbiz132.hostername.com . how to solve this
Yes, you can get rid the "via" part. Here's the details:
1) SPF and DKIM
Firstly, you would need to set an SPF record for the domain you are sending emails from and enable DKIM as well. These are primarily for identifying your messages against spam.
2) "From: anything#yourdomain.com"
Secondly, make sure you are setting the “From: ” header to be an email address on the domain you are sending messages from. Don’t pretend to be someone else. Use “From: someone#abc.com” if you are sending the messages from abc.com, rather than anything else, such as blah#def.com, or yours#gmail.com, or whatever. If you want the recipient to reply to your Gmail email instead of your domain email, use the “Reply-To: ” header. “From: ” must always be the domain email that you are sending the email from.
3) "Return-Path: return#yourdomain.com"
Thirdly and most importantly, set the “Return-Path: ” header to be the same domain as that of the “From: ” header. Use the 5th parameter of the mail() function for this:
mail('recipient#example.com', 'Subject', "Message Body", $headers, '-freturn#yourdomain.com')
So the Return-Path of this message would be “return#yourdomain.com” (the email address immediately following the -f switch). The $headers parameter should contain all the necessary message headers. Make sure “From: ” is something#yourdomain.com.
After these steps and measures, Gmail should now completely trust your messages from yourdomain.com. The ‘via‘ field of your messages should be gone and the ‘mailed-by‘ field as well as the ‘signed-by‘ field should be correctly showing up as yourdomain.com.
Hope it helps!
This question already has answers here:
How do I prevent mails sent through PHP mail() from going to spam? [duplicate]
(6 answers)
Closed 9 years ago.
Below is header to sent to user:
$to="$mail";
$sub="Thank you!";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type:text/html; charset=iso-8859-1\r\n";
$headers .= 'From: example.com <noreply#example.com>' . "\r\n";
$msg="Dear $nme ,<br/> We received a request to recover your password.<br/> Your Password is $pss .";
$response =#mail($to,$sub,$msg,$headers);
If i send it through diff sever it goes to inbox.
How can I prevent email going to spam?
$to='example#gmail.com';
$subject='Application Form ';
$message='testing';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: admin <admin#gmail.com>' . "\r\n";
if(mail($to,$subject,$message,$headers))
{
echo "Mail Successfully Sent..";
exit;
}
It works perfectly to me. You can also use SMTP MAIL instead of this.
I think generally, a mail is termed as spam or not spam on the receiving end of it, not the sending end - or else any spammers would simply say that all of their messages are not spam, completely defeating the purpose. Thus, you can't just force a message to go to a sender's inbox.
However, what you may need to do is see if the machine that you're using to send mail is currently listed on any spam blocklists, and if so, take the necessary steps to remove it from those blocklists.