Here I am trying to send the email with some text highlighted in bold.
Here is what I have tried but I am getting the tags as it is but I am not getting the bold font. How can I do this?
Here is what I have done:
$mail->Body = PROPOSE_STATEMENT." <b>".$product_name."</b> ".REJECTED;
Here I have used the html <b></b> tags in the php to make the text bold but I am getting output like this:
you proposed <b>TVS Apache RTR 160</b> Has been
You have to send an HTML Mail.
Set to, subject and headers (Set HTML in header)
$to = 'bob#example.com';
$subject = 'Request';
$headers .= "MIME-Version: 1.0\r\n";
//Set the content-type to html
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
Now you can use HTML
$message = '<html><body>';
$message .= '<h1>Hello, World!</h1><b>bold</b>';
$message .= '</body></html>';
And send the Mail
mail($to, $subject, $message, $headers);
If you are using
PHP Mailer then add this line in your script
$mail->IsHTML(true);
You need to set the HTML content type in the email header
"Content-Type: text/html; charset=ISO-8859-1\r\n"
Your code doesnt indicate some standard email sending method that im aware of so i cant help with actual code
There's a really good answer about this in this stackoverflow question which covers general HTML formatting.
You pretty much either need to set the content type of the e-mail by doing:
Content-type: text/html; charset=iso-8859-1
or, if using PHP mailer, use the following to set the e-mail to be HTML:
$mail->IsHTML(true);
Related
I am keep getting the source code in outlook 2013. I have read a lot of stackoverflow questions, tried all the recommended solutions, none of the helped tho.
here is my php
$test1 = "test string";
// Retrieve the email template required
$message = file_get_contents('email-templates/template1.html');
// Replace the % with the actual information
$message = str_replace('%test1%', $test1, $message);
//echo $message;
$to = 'test#gmail.com';
$email_subject = "test";
$email_body = $message;
$headers = "From: $to\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
mail($to,$email_subject,$email_body,$headers);
using only \n instead of \r\n, and took care of the order (this one was presented), but still working on gmail, phone, bot does not in Outlook.
any more suggestions?
I suggest that rather trying to re-invent (or fix) the wheel that you use PHPMailer. I've been using it for years to send HTML emails that render properly in Outlook.
your code looks a lot like the example in the manpage http://php.net/manual/en/function.mail.php
try ending your lines with \r\n (CR-LF) not just newlines, who knows
You can back up a step, copy-and-paste the example from php.net and see whether the problem is really on the Outlook side. You can also pull up html emails from your inbox, and see what they're doing different (try to copy-and-paste send a copy of a good html email from within php)
As to reinventing the wheel, if mail() predates PHPMailer, arguably it's the latter that did the reinventing...
the solution was
$headers .= "MIME-Version: 1.0\n" ;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
I have a form that will dynamically send emailers . This form takes the email id of the recipient ,the subject and the body content.
I am using PHPMailer class to go about this. When it comes to plain text ,the emailers work just fine. But I want to add a functionality where the users can paste html into the body part so that the emailer can parse/read them and send the html'ized version of the emails.
I tried this , but it didn't work as the the entire HTML was mailed as text.
$email_msg = htmlentities($_POST['mail_msg'], ENT_QUOTES, "UTF-8");
Any advice would be helpful .
Thanks in advance.
Did you set the PHPMailer default to HTML:
$mail->IsHTML(true);
Modify your mail headers :
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset: utf8\r\n";
I have used used the PHP Language for Sending the email and HTML tags are not rendering in the gmail account sometimes.I have used Content Type as - charset="iso-8859-1" I have attached the image.
And also am receiving the Message ID, which should not be come in the mail.
I don't recommend/use php built in mail() function to send and receive emails. Use php open source libraries like PHPMailer and SwiftMailer. I have been using PHPMailer after facing many issues when using mail() alone. Very easy to implement and has lots of features. You don't have to spend your valuable time for email sending related development.
http://phpmailer.worxware.com/
http://swiftmailer.org/
If the HTML isn't rendering, that usually means the headers weren't set properly.
Try this:
<?php
//change this to your email.
$to = "m#m.com";
$from = "m#m.com";
$subject = "This is HTML email";
$message = "
<b>htmlemail....</b> <br>
<a href='http://www.google.com'>Google</a>";
// To send the HTML mail we need to set the Content-type header.
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: $from\r\n";
mail($to, $subject, $message, $headers);
echo "Message sent..";
?>
From http://www.webhostingtalk.com/showthread.php?t=416467
I am currently processing a form with text and making an email out of the text.
I am facing two problems:
1) If I just take the text as is, I get \n\r that appear in the email whenever the person uses line breaks.
2) If I use nl2br() function on the input text, I get strings in my email.
Is there a correct or "best practice" way handling such situations?
Thanks,
Alex
You should add appropriate headers to your email
// To send HTML mail
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
before using nl2br()
// Then mail it
mail($to, $subject, nl2br($message), $headers);
I've never done html e-mail before, I've just set up php mail using http://www.postmarkapp.com
I was wondering how I would go about sending php mail as html?
Does anybody have any previews of a php page sending html e-mail I can look at to get the jist of how it works?
Currently I'm just putting text into a variable and sending it as a message, how is it done for html?
Regards
Do you still want to use Postmark to send emails?
In Postmark, you set the TextBody property to the text version of your message, and the HtmlBody property to the html version of it. It is good practice to always include both. Depending on whether your user's email client supports HTML or not, the appropriate message form is rendered. Read more on this here.
Edit: Added an example. I generally like splitting my string into separate lines so that I can indent it nicely like a real HTML file. Of course, if you used templates, that would make it so much better.
$htmlBody = "
<html>
<body>
Thank you for using our app!<br />
- Super Awesome App Team
</body>
</html>
";
http://phpmailer.worxware.com/
This is the best class I've found to send mail with PHP. It allows HTML formatting with alternate plain text part, as well as attachments. It also seems to filter out spam quite well when used for online forms.
Put the html code inside the variable where you need as you are doing while creating web pages and set the mail header to text/html.
$headers.= 'MIME-Version: 1.0' . "\r\n";
$headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers.= "From: eaxfd#gmail.com \r\n";
$headers.= "Reply-To: eaxfd#gmail.com \r\n";
mail($to,$subject,$message,$headers);
You just have to include html headers in your call to the mail() function:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1';
mail($to, $subject, $message, $headers);