I got a code like this:
$headers = '';
//$headers .= 'Reply-To: "site\'s name" <newsletter#example.com>'."\r\n";
//$headers .= 'From: "site\'s name" <newsletter#example.com>'."\r\n";
$headers .= 'MIME-Version: 1.0'."\r\n";
$headers .= 'Content-type: text/html; charset=utf-8'."\r\n";
mail($_POST['email'], stripslashes($result['title']), $message, $headers);
As long as those two lines are commented out, it sends emails correctly. Otherwise - it just doesn't. Without giving any error or even notice. It worked (uncommented code) until yesterday and now it stopped. Any ideas, why would it happen? I cannot use Swift or anything like that, because it's not my project.
Edit: incorrect quoting, but that wasn't the problem.
Edit: damn, it was just server admins, they blocked all mails with headers from non-existing accounts. I just had to create such mailbox, and i started working back again...
You have an error on site's name try with correct quoting
$headers .= 'Reply-To: "site\'s name" <newsletter#example.com>'."\r\n";
$headers .= 'From: "site\'s name" <newsletter#example.com>'."\r\n";
You can add header as the code below. Remove unwanted single quotes and double quotes. Just simple write as below.
$headers = "From: site name <newsletter#example.com> \r\n";
$headers .= "Reply-To: site\'s name <newsletter#example.com> \r\n";
$headers .= "MIME-Version: 1.0\r\n";
Related
Hello: been doing html emails with php mail() without any problems - but having a heck of time trying to add a picture properly. I load in the content of the email into a variable called $messageContent
here is my actual calling of the mail() function:
$headers = "From: BBT Admin - " . $emailFrom . "\r\n";
$headers .= "Reply-To: ". $emailFrom . "\r\n";
$headers .= "BCC: ".$bccEmail."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($emailTo,$subject,$messageContent,$headers);
All of this works fine - only have problems depending on what I put in the "content" variable...
I basically keep appending to the content variable - building the content one piece at a time...here is the part that is the problem:
$messageContent="";
$messageContent.="<a
href='http://www.example.com'>example.com</a>";
$messageContent.="<br style='clear:both;'/>";
$messageContent.="<br/><br/>";
$messageContent.="<img src='http://example.com/wp-content/uploads/2018/03/Capture_bbtmap3.png'/>";
So this doesnt work that well - so if anyone can help on this it would be greatly appreciated!
I am using PHP's mail() function to generate mails. Generated mail looks absolutely fine with correct email ids in 'To' and 'Cc' but mail gets delivered to 'To' only and not to 'Cc'.
Here is the code
$headers = "From: xyz#abc.com \r\n";
$headers .= "Reply-To: xyz#abc.com";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Cc: email1#abc.com ; email2#abc.com" . "\r\n";
$headers .= "X-Mailer: PHP/". phpversion();
$headers .= "Content-type: text/html; charset=iso-8859-1". "\r\n";
mail($to, $subject, $message, $headers);
Our organsation uses 365 for mails, and this issue has mostly cropped up since we started migration. I went through the php mail log and it seems to be fine to me.
How to fix this issue? Any suggestions?
PS. I feel that this issue has cropped up only since we moved to 365 some time ago. Also, does id 'xyz#abc.com' (sender) need to exist?
$headers .= "Reply-To: xyz#abc.com";
Where is the "\r\n" on this line?
For a proper and standardized PHP mailing library which will help your team to properly build emails, take a look at:
https://github.com/PHPMailer/PHPMailer
Replace the ; to an , in your CC line:
$headers .= "Cc: email1#abc.com ; email2#abc" . "\r\n";
Or send your mails over IMAP with a class like PHPMailer https://github.com/PHPMailer/PHPMailer
Okay okay, I know there are a million of these threads, but I did my best to look through them and could not find one that actually solved the problem for me. Any help is greatly appreciated, as depending on the browser it either hides the whole thing or shows it in plain text.
Here's what I'm using:
$headers = 'From: coupons#madisoncoupons.com\r\n';
$headers .= 'Reply-To: coupons#madisoncoupons.com\r\n';
$headers .= 'MIME-Version: 1.0\r\n';
$headers .= 'Content-type: text/html; charset=ISO-8859-1';
mail($email,$subject,$content,$headers);
$content starts and ends with html and body tags, with a style tag in the beginning of the body with some CSS in it.
You'll want to use the correct quotes. "\r\n" and '\r\n' are two completely different things.
Read up on how PHP handles strings if you're rusty.
as #tadman said above, you have to modify your headers to the following
$headers = 'From: coupons#madisoncoupons.com' ."\r\n";
$headers .= 'Reply-To: coupons#madisoncoupons.com' . "\r\n";
Use this
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From: <info#example.com>' . "\r\n";
mail($email,$subject,$content,$headers);
I have a mail function with the standard parameters:
mail($to, $subject, $message, $headers);
Where:
$headers = "From: admin#mysite.org";
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
Now, I'm trying to get the sent e-mails to show 'My Site' as the sender instead of 'admin#mysite.org' but if someone responds to the mail it still needs to go to admin#mysite.org.
I've tried putting "My Site" in the "From" field before and after the e-mail address but it just appends to the address. I've tried appending it to the $headers variable but that messes the whole e-mail up. I've also tried adding it this way:
$headers .= "\r\nMy Site";
but that doesn't seem to do anything.
I know this can't be complicated as I've seen it done a hundred times, but I can't seem to find a straight-forward answer for this - how do I 'mask' the admin e-mail with the site name but still keep it as the address any response goes to?
Change your From: header to "From: My Site <admin#mysite.org>"
$headers = "From: My Site <admin#mysite.org>";
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
From the PHP Docs.
There is the "From: something <something#something.com>"; header, and then there is also the optional fifth parameter of mail() which allows you to override the from setting that may or may not be set in php.ini.
<?php
$to = 'name#domain.com.au';
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$header .= "From: Name <noreply#domain.info>" . "\r\n";
$fifthp = '-f noreply#domain.info';
mail($to, $subject, $message, $header,$fifthp);
?>
My client has a Wordpress content management system to which I added a simple contact form with a php form handler. The contact form sends the information by email correctly to all three of my email addressses, but when I change to my client's email address the email never arrives. I have run out of ideas where I could look for the problem. No it does not go to his junk mail folder. :)
Sounds like the email is being routed "internally" through your clients network and not out onto the internet. The chances are they have some restrictions on what machines can be used to send emails internally, or the mail routing system sees the internal email as being "different" and does something odd with it.
Try using (from a cli) :
echo "Testing " | mailx -"Test Subject Line" user#company.co.uk
What is the mail function that you are using? Do you attach a header to it? It sounds like it is being marked as spam from the exchange server. What I use (and have always worked for me) is something like this:
`
function mailme($sendto,$sendername,$from,$subject,$sendmailbody,$bcc="")
{
$subject = nl2br($subject);
$sendmailbody = nl2br($sendmailbody);
if($bcc!="")
{
$headers = "Bcc: ".$bcc."\n";
}
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8 \nContent-Transfer-Encoding: 8bit\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: PHP/"."MIME-Version: 1.0\n";
$headers .= "From: " . $from . "\n";
$headers .= "Content-Type: text/html\n";
mail("$sendto","$subject","$sendmailbody","$headers");
}
`