PHP: Email headers - php

I am sending email through PHP and I want to change the "sent by" email in the headers:
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: test#test.com' . "\r\n";
$headers .= 'Reply-To: test#test.com' . "\r\n" .'X-Mailer: PHP/' . phpversion();
I am also attaching the image for reference:
I want to change the highlighted email address. Thanks in advance

Related

PHP email header FROM field not displaying correctly

I need help getting the FROM field in the email to be a specific email address. As of now it is coming out something like this. Looks like its grabbing info off my hosting companies server.
ipw.xxxxxxxxx#boscustweb1302.eigbox.net
All other features of email work great. My $headers are as follows:
$to = $email;
$subject = "ORDER # $tranid";
$headers = "From: info#xxxxxx.com";
$headers = "MIME-Version: 1.0";
$headers = "Content-type: text/html; charset=iso-8859-1";
PHP manual sugest this. Which is pretty much what I am doing, I think.
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
They do use implode, but I don't think I need it the way I have mine setup:
mail($to, $subject, $message, implode("\r\n", $headers));
Tried this with no success:
$to = $email;
$subject = "ORDER # $tranid";
$headers .= "From: info#xxxxxx.com";
$headers .= "MIME-Version: 1.0";
$headers .= "Content-type: text/html; charset=iso-8859-1";
Found the answer with the help of #chris85
$headers = "From: info#xxxxx.com\r\n".
"MIME-Version: 1.0" . "\r\n" .
"Content-type: text/html; charset=UTF-8" . "\r\n";
Keeps HTML format in tack and shows FROM field correctly.

PHP email sending issue

My contact form is sending emails out but for someone reason, I am not receiving emails in my gmail account. I am receiving emails on other email providers like Yahoo. So I think that there is a problem with my headers.
$headers = 'From: ' .$email . "\r\n" .
'Reply-To: ' .$email . "\r\n" .
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
You have a period instead of a semi-colon
'Reply-To: ' .$email . "\r\n" .
^
Change it to:
$headers = 'From: ' .$email . "\r\n" .
'Reply-To: ' .$email . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
which is breaking your headers

HTML Email occasionally sending source code

At my company, we have had several clients claim that their order confirmation emails are coming through just as the HTML source, not formatted at all. However the majority of our clients are receiving their emails through fine.
I think I may have found a link which explains why only some clients receive the unformatted email, however I'm not sure of the cause. It seems that users with a custom domain name for their email address are experiencing the problems and regular email domains such as #gmail.com or #icloud.com are working fine.
The problem is not related to the client used to view the email as I have been able to replicate the problem with my private domain name and the source code is displayed in all clients.
Any idea what would be the cause of this?
Here are my headers:
$headers = "From: ".$from."\r\n";
$headers .= "Reply-To: ".$from."\r\n";
$headers .= "Return-Path: ".$from."\r\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1";
Try following headers for HTML Email...
$from = $from . ' <' . $from . '>';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=utf-8" . "\r\n";
$headers .= 'From: ' . $from . "\r\n";
$headers .= 'Reply-To: ' . $from . "\r\n";
$headers .= 'Return-Path: ' . $from . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n";
$headers .= 'X-Originating-IP: ' . $_SERVER['SERVER_ADDR'] . "\r\n";

Error in Sending Email using php

I am sending email using php script and i am setting from address as
$headers = "MIME-Version: 1.0" . "$from" . "\r\n";
$headers.= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
So, the mail coming to my mail address as from support#mysite.com, But i need to set from address as support#gmail.com.But it is not coming with the modified from address. So, please help to solve this problem..
You try this...
<?php
$to = 'nobody#example.com';
$subject = 'Mail Subject';
$message = 'Test';
$headers = 'From: support#gmail.com' . "\r\n" .
'Reply-To: support#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Hop this will works...
Replace header text,
$headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= "X-Mailer: PHP \r\n";
$headers .= "From: YourName <support#gmail.com>";
To get more information about mail function
may this help you.

PHP Mail not formated for some reason

I am new to PHP and send an email using following code
<?php
$to = 'to#xyz.com';
$subject = 'the subject';
$message = '<table dir="rtl"><tr><td>'. "\r\n";
$message .= '<b>This is Bold</b></br> <i> This is Italics</i></br>شطب 14 مرشحا لمجلس الأمة الكويتي'. "\r\n";
$message .= '</td></tr></table>';
//Headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n" .
$headers .= 'From: from#xyz.com' . "\r\n";
$headers .= 'Reply-To: replyto#xyz.com' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
ini_set ( "SMTP", "smtp.xyz.com" );
mail($to, $subject, $message, $headers);
?>
I can receive the email and it display the arabic also but it also show the from email address in the body of the email.
And other issue is that arabic is RTL even after mentioning in table dir-"RTL" it still show the message as LTR.
Example of Email Received
from#xyz.com
This is Bold
This is Italics
شطب 14 مرشحا لمجلس الأمة الكويتي
You could try using the alternative of CSS2 style:
style="direction:RTL; unicode-bidi:embed;"
Extra reading: http://www.i18nguy.com/markup/right-to-left.html

Categories