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.
Related
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.
I have a contact form and want to format the output email in HTML and use charset utf-8 as I need some special character. I have following code, but it's not working.
Edit: The email is sent, but without html and utf-8.
<?php
if ($_POST["email"]<>'') {
$ToEmail = 'contact#domain.com';
$EmailSubject = 'Email Subject';
$mailheader = 'From: donotreply#domain.com' . "\r\n" .
'Reply-To:' .$_POST["email"]. "\r\n" .
'X-Mailer: PHP/' . phpversion();
'MIME-Version: 1.0'."\r\n".
'Content-Type: text/html; charset=utf-8'."\r\n".
$MESSAGE_BODY .= "<b>Navn:</b> ".$_POST["name"]."\r\n";
$MESSAGE_BODY .= "<b>Telefon:</b> ".$_POST["telephone"]."\r\n";
$MESSAGE_BODY .= "<b>Email:</b> ".$_POST["email"]."\r\n\r\n";
$MESSAGE_BODY .= "".nl2br($_POST["message"])."\r\n";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
Try changing header from
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
to
$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
Its better use PHPMailer This will allow you to send mails via a SMTP server
I found that the only thing that was wrong was the order of the code. By moving 'X-Mailer: PHP/' . phpversion(); below Content-Type the mail is encoded correct.
This is how I fixed it:
$mailheader = 'From: donotreply#domain.com' . "\r\n" .
'Reply-To:' .$_POST["email"]. "\r\n" .
'MIME-Version: 1.0'."\r\n".
'Content-Type: text/html; charset=utf-8'."\r\n".
'X-Mailer: PHP/' . phpversion();
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
I am using the mail function
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: <>' . "\r\n";
$headers .= 'Cc: ' . "\r\n";
$mail_sent = #mail( $to, $subject, $message, $headers );
I want to pass the email-value for "From:" as a variable. Can this be done? And how can I pass other values like mobile number on to the mail?
Pass the email address($fromAddress) as a header
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: <'.$fromAddress.'>' . "\r\n".
'Reply-To:'.$fromAddress. "\r\n" .
$headers .= 'Cc: ' . "\r\n";
$mail_sent = #mail( $to, $subject, $message, $headers );
From example2 in the docs..
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
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