For some reason my php mail() function does not send html,
Instead of link it shows just shows link as plain text.
Any ideas?
this is the headers I used:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
// Additional headers
$headers .= 'From: My Automated Message <robot#mysite.cc>' . "\r\n";
And invoked as follows:
try {
if (#mail($to_email, $subject, $message, $headers)){
echo "<span style=\"color:#0D0; font:10pt Tahoma;font-weight:bold;\">{$SENT_MESSAGE}</span><br><br>";
return true;
} else {
$tmp=error_get_last();
throw new Exception($tmp['message']);
}
} catch (Exception $e) {
echo "<span style=\"color:red; font:10pt Tahoma;font-weight:bold;\">Error: ".$e->getMessage()."</span><br><br>";
}
I also tried to send the mail without headers, but then again it shows the link as plain text like this: link
Try this header
$headers = 'From: Name<address#domain.com>' . "\r\n" .
'Content-Type: text/html; charset=UTF-8' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-Transfer-Encoding: base64' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
Check this
$from='robot#mysite.cc';
$headers ='';
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$from.' '. "\r\n";
mail($to_email, $subject, $message, $headers);
Related
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
By mistake, I added from-address as to-address in mail-function.
It sends mail to both to-address and from-address why? Is it documented anywhere?
$from = 'from_user#gmail.in';
$to = 'to_user#gmail.com';
$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";
$message = json_encode(compact('to', 'from', 'headers'));
// NOTE THE FROM INSTEAD OF TO
mail($from, $subject, $message, $headers);
Further to the comments and to highlight your request for reference. Here is a snippit from the php manual for reference. Notice the first line of additional headers:
// To send HTML mail, the Content-type header must be set
$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);
So you are sending an email both through the mail($to... (which happens to be the $from in your case) but you are also sending the $to in the $headers declaration.
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.
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
I'm trying to create a php script that will handle a mailing list for me using a mySQL database, and I have most of it in place. Unfortunately, I can't seem to get the headers to work right, and I'm not sure what the problem is.
$headers='From: noreply#rilburskryler.net \r\n';
$headers.='Reply-To: noreply#rilburskryler.net\r\n';
$headers.='X-Mailer: PHP/' . phpversion().'\r\n';
$headers.= 'MIME-Version: 1.0' . "\r\n";
$headers.= 'Content-type: text/html; charset=iso-8859-1 \r\n';
$headers.= "BCC: $emailList";
The result I'm getting on the recieving end is:
"noreply"#rilburskryler.net rnReply-To: noreply#rilburskryler.netrnX-Mailer: PHP/5.2.13rnMIME-Version: 1.0
To have names, as opposed to email addresses shown, use the following:
"John Smith" <johnsemail#hisserver.com>
Easy.
Regarding the broken line breaks, that is because you are enclosing the text in apostrophes rather than quotation marks:
$headers = array(
'From: "The Sending Name" <noreply#rilburskryler.net>' ,
'Reply-To: "The Reply To Name" <noreply#rilburskryler.net>' ,
'X-Mailer: PHP/' . phpversion() ,
'MIME-Version: 1.0' ,
'Content-type: text/html; charset=iso-8859-1' ,
'BCC: ' . $emailList
);
$headers = implode( "\r\n" , $headers );
Within a single quoted string, only the escape sequences \' and \\ are replaced by ' and \ respectively. You need to use double quotes to have the escape sequences \r and \n to be replaces by the corresponding characters:
$headers = "From: noreply#rilburskryler.net \r\n";
$headers.= "Reply-To: noreply#rilburskryler.net\r\n";
$headers.= "X-Mailer: PHP/" . phpversion()."\r\n";
$headers.= "MIME-Version: 1.0" . "\r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1 \r\n";
$headers.= "BCC: $emailList";
You could also use an array to collect the header fields and put them later together:
$headers = array(
'From: noreply#rilburskryler.net',
'Reply-To: noreply#rilburskryler.net',
'X-Mailer: PHP/' . phpversion(),
'MIME-Version: 1.0',
'Content-type: text/html; charset=iso-8859-1',
"BCC: $emailList"
);
$headers = implode("\r\n", $headers);
$to = 'SendersName#domain.com';
$to .=', ' . $_POST['Femail'];
$subject = 'Contact Us Form';
// message
$message ="<html>
<head>
<title>Email title</title>
</head>
<body>
<h3>important message follows</h3>
<div>
you are being brought this email to be safe.
</div>
</body>
</html>";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: SendersEmailName <SendersEmailName#domain.com>' . "\r\n";
$headers .= 'From: YourName <YourName#domain.com>' . "\r\n";
$headers.='X-Mailer: PHP/' . phpversion()."\r\n";
$headers.= "BCC: $emailList";
mail($to, $subject, $message, $headers);