Mail is not in proper format in yahoo - php

when user register or clicks on forgot password mail is send. it looks fine in gmail and other accounts but it is shown in html format in yahoo.
code is
$embody="<p>Dear ".$data['name']." </p>
<p> Thank you for registering with JCA Associates. Please log into your account to complete your candidate profile and upload your CV </p><br/>
<p> JCA Associates</p>
<p> <img src='".$_SERVER['HTTP_HOST']."/themes/images/logo.png' width='100' height='60'></p>";
//} else {
// $embody="<p>Dear ".$data['name']." </p><p> Thank you for registration with us!</p><p> Best regards,<br/> JCA Team</p>";
//}
$message = '<html dir="ltr" lang="en">' . "\n";
$message .= ' <head>' . "\n";
$message .= ' <title>Welcome to JCA Associates</title>' . "\n";
$message .= ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
$message .= ' </head>' . "\n";
$message .= ' <body><p> ' . html_entity_decode($embody, ENT_QUOTES, 'UTF-8') . '</body>' . "\n";
$message .= '</html>' . "\n";
it is shown like this in yahoo.
http://screencast.com/t/wDWixSBI

I'm guessing you haven't added the HTML headers to the function that triggers the email call. If you're using mail, add these headers:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
Where $subject, $to, and $headers have the appropriate values.

Try to adding following to your email code and it will work like a charm.
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8 \n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: PHP/"."MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html\n";
mail("$sendto","$subject","$embody","$headers","$from");

Related

CSS won't work when sending HTML email with wp_mail()

I am trying to send a HTML mail with the Wordpress function wp_mail() like this:
add_filter( 'wp_mail_content_type', function( $content_type ) { return 'text/html'; });
$headers = 'From: '. $current_user->user_firstname . ' ' . $current_user->user_lastname .' <'. $current_user->user_email .'>' . "\r\n";
wp_mail( $_POST['email'], $_POST['subject'], $_POST['mail_text'], $headers);
remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
All HTML tags like <strong>, <li>, <p> etc. come with HTML format. But when I try to change the color using HTML or CSS like <li style="color:red">Word</li> or <li color="red">Word</li> it won't work and appears as blank text.
What am I doing wrong?
The text/message you send is in $_POST['mail_text'] coming from a textarea, right?
Did you echo out the content of $_POST['mail_text']? Is it ok before sending?
Try single quotes:
<li style='color:#f90'>Hello World</li>
and check if somewhere a script calls strip_tags to remove html tags.
$headers = "MIME-Version: 1.0" . "\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\n";
$headers .= "X-Priority: 1 (Higuest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$headers .= "From: Approprice <".$mailfrom.">" . "\n";
$headers .= "Return-Path: Approprice <".$mailfrom.">" . "\n";
$headers .= "Reply-To: Approprice <".$mailfrom.">";
user this headers in email for sending html

PHP mail function outlook UTF8

My script:
$message = "
<html>
<head>
<title>Birthday Reminders for August</title>
<style>td,tr{border:solid 1px black;}</style>
<meta charset='UTF-8'>
</head>
<body>
<table>
<tr><td>სახელი</td><td>{$_POST['firstname']}</td></tr>
<tr><td>გვარი</td><td>{$_POST['lastname']}</td></tr>
<tr><td>დაბადების თარიღი</td><td>{$_POST['birthday']}</td></tr>
<tr><td>მოქალაქეობა</td><td>{$_POST['cityzen']}</td></tr>
<tr><td>პირადი ნომერი</td><td>{$_POST['id_number']}</td></tr>
</table>
</body>
</html>
";
// To send HTML mail, the Content-type header must be set
//MUSHA
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; utf-8' . "\r\n";
// Additional headers
$headers .= 'To: Mary <aaa.wwww#gmail.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' . "\n";
// Mail it
mail($to, $subject, $message, $headers);
I've tested it on gmail.com, yahoo.com, outlook.com and everything works great.
but in MS Outlook it has problem of UTF-8.
Try using:
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
try adding
header("Content-type:text/html;charset=utf-8");
to in top of your php file. Also Which version of Outlook you use?

PHP/HTML Code Renders as Text in Email: Any Insight?

I've tried many header changes to no avail.
Could it be the email server? Or am I missing something crucial?
I would like to see more than the code rendered as text in the resultant email.
Thanks!
<?php session_start(); ?>
<?php
$body = '';
$body .= '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping Cart</title>
</head>
<body>
<h1>Here is a Copy of Your Order</h1>';
$body .= '<table>
<tr>
<th>Product</th>
<th>Cost</th>
<th>Units</th>
<th>Subtotal</th>
</tr>';
$total = 0;
foreach($_SESSION['cart'] as $item) {
$body .= "<tr>
<td>{$item['item']}</td>
<td>\${$item['unitprice']}</td>
<td>{$item['quantity']}</td>
<td>$".($item['unitprice'] * $item['quantity'])."</td>
</tr>";
$total += ($item['unitprice'] * $item['quantity']);
}
$body .= '</table>';
$body .= "<p>Grand total: \$$total</p>";
$body .='</body></html>';
}
?>
<?php
echo $body;
$to = 'xxxx#gmail.com';
$subject = 'Fill This Order';
$headers = 'From: xxxx#gmail.com' . PHP_EOL;
$headers .= 'MIME-Version: 1.0' . PHP_EOL;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL;
mail($to, $subject, $message, $body, $headers);
?>
here is a tutorial about how to send a mail with html code in it: Sending Nice HTML Email with PHP
work around it, what they got works.
as you can easly see there, the headers sent is:
$to = 'bob#example.com';
$subject = 'Website Change Reqest';
$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "CC: susan#example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
they diffrence you can see is mostly: \r\n in every end of line.
this could be your problem because without it it can be something like:
$headers .= 'MIME-Version: 1.0' . PHP_EOL . 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL;
and in headers... this could be: 'MIME-Version: 1.0Content-type: text/html; charset=iso-8859-1
and not work..
i think you should take a look in the link i added and modify your code by it.
EDIT:
i think i found it! you sent mail($to, $subject, $message, $body, $headers);
while PHP mail function uses:
mail(to,subject,message,headers,parameters)
you can see here how to use the mail function: The PHP mail() Function
the thing i think heppend is you sent $message which does not exsits and the headers are not sent as they should.
Have you tried swapping out PHP_EOL for "\r\n"?

php send mail script encoding issue on windows

I have problem with non english characters with this e-mail script. If I set the script to send e-mail to my gmail account, I have no problem. However, if I set the script to send email to my domain account and if i open the email with windows live mail or with microsoft outlook then the e-mail is not readable. I must to go to encoding menu, and then select the utf-8, and then i can read the email.
If I open the mail on iMac mail client, i have no problem.
My customer see this as big problem and want me to solve it. Anyone can help?
Here is the code:
<?php
// send the form to the specify email
// CONFIG VARS
$subject = "mysite.com | contact form";
$to = "myaccount#somemail.com";
$from = 'another#somemail.com';
//data
$msg = "Name: " .$_POST['namesup'] ."<br>\n";
$msg .= "Email: " .$_POST['emailsup'] ."<br>\n";
$msg .= "Phone: " .$_POST['phonesup'] ."<br>\n";
$msg .= "Message: " .$_POST['yourtextsup'] ."<br>\n";
//Headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <".$from. ">" ;
//send
mail($to, $subject, $msg, $headers);
?>
Any help will be deeply appreciated.
Zoran
Checkout this code it will work for me,
<?php
$subject = "mysite.com | contact form";
$to = "myaccount#somemail.com";
$from = 'another#somemail.com';
$msg = '<html>
<head>
</head>
<body>
<p>
Name: ".$_POST['namesup']."<br>
Email: ".$_POST['emailsup']."<br>
Phone: ".$_POST['phonesup']."<br>
Message: ".$_POST['yourtextsup']."<br>
</p>
</body>
</html>';
$headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= "X-Mailer: PHP \r\n";
$headers .= "From: <".$from. ">" ;
mail($to,$subject,$msg,$headers);
?>
This line $headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n"; is resolved your issue of like Arabic language or others.
I would suggest making sure your message is valid HTML, including the <html> and <head> tags, and also make sure you include the <meta http-equiv="Content-Type" content="text/html charset=UTF-8" /> tag. So:
//data
$msg = '<html><head><meta http-equiv="Content-Type" content="text/html charset=UTF-8" /></head><body>';
$msg .= "Name: " .$_POST['namesup'] ."<br>\n";
$msg .= "Email: " .$_POST['emailsup'] ."<br>\n";
$msg .= "Phone: " .$_POST['phonesup'] ."<br>\n";
$msg .= "Message: " .$_POST['yourtextsup'] ."<br>\n";
$msg .= '</body></html>';
Try changing your scripts charset to:
<?php
// send the form to the specify email
// CONFIG VARS
$subject = "mysite.com | contact form";
$to = "myaccount#somemail.com";
$from = 'another#somemail.com';
//data
$msg = "Name: " .$_POST['namesup'] ."<br>\n";
$msg .= "Email: " .$_POST['emailsup'] ."<br>\n";
$msg .= "Phone: " .$_POST['phonesup'] ."<br>\n";
$msg .= "Message: " .$_POST['yourtextsup'] ."<br>\n";
//Headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1";
$headers .= "From: <".$from. ">" ;
//send
mail($to, $subject, $msg, $headers);
?>

php email not reading html

For some reason, the html fails to render in gmail, but renders in hotmail.
Its vital that gmail reads the html, so I wonder which changes I should make to this header.
$from = "info#email.co";
$headers = "From: bob at info.co <" .($from) . ">\n";
$headers .= "Reply-To: ".($from) . "\n";
$headers .= "Return-Path: ".($from) . "\n";;
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-Mailer: PHP". phpversion() ."\n";
The message starts of as:
$message = '<html><body>';
$message .= "<p>";
$message .= "Hi $clean_fullName, <br><br>";
$message .= " Well, I've looked at what you shared with me and I'm delighted to include my personal learning suggestions that I hope will help you achieve your startup goals.";
$message .= "<br><br>";
$message .= "If they aren't quite what you're looking for, I take criticism better than most Entrepreneur Wizards
so please let me know by responding to this email and I'll take another look for you.";
$message .= "<br><br>";
$message .= "
$message .="<br><br>Otherwise, happy learning!<br><br>";
$message .= "<b>Total Learning time: </b>";
// create an array of all the duration
$counter = array();
foreach($data as $item) {
// add each duration item to the array after every iteration
array_push($counter, "{$item['duration']}");
}
//record and display the result to the user
$message .= array_sum($counter);
$message .= " hours <br><br>";
foreach($data as $item) {
$message .= "<b>
&#10139<a style='color:#FF6400; text-decoration: none' href='{$item['link']}'>{$item['title']}</a></b><br>";
$message .= "Format: {$item['format']} <br>";
$message .= "Cost: ${$item['costs']} <br>";
$message .= "Estimated Duration: {$item['duration']} hours<br>";
$message .= "<br>";
}
$message .= " If you have any questions, do not hesitate to reach out to us. <br><br>";
$message .= "</p>";
$message .= '</body></html>';
mail
mail($to,$subject,$message,$headers);
I am still learning :)
but this should work
$from = "info#email.co";
$headers .= 'From: bob at info.co <$from>' . "\r\n";
$headers .= 'Reply-To: <$from> ' . "\r\n";
$headers .= 'Return-Path: <$from>' . "\r\n";
$headers .= 'MIME-Version: 1.0 ' . "\r\n";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
$headers .= 'X-Priority: 3' . "\r\n";
$headers .= 'X-Mailer: PHP". phpversion()' . "\r\n";
Answer from comments
$message = '<html><body>';
u should do like this
$message .= '<html>'. "\r\n";
$message .= '<body>' . "\r\n";
You have too much errors in writing missing dot semi etc
as i see your html tag wasn't open at all.
there is lot options to write this template
1.
<?php
// multiple recipients
$to = 'aidan#example.com' . ', '; // note the comma
$to .= 'wez#example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</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: 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);
?>
2.
$message.= 'blasldl asdas d asdas' . "\r\n";
$message.= ' sdfadasdasd dsad' . "\r\n";
U can change "\r\n"with $rn = "\r\n"; and use it fast as $rn
$message.= 'blasldl asdas d asdas' . $rn;
$message.= ' sdfadasdasd dsad' . $rn;
u can try those solutions and tell me whats happening .
and dont place all email under<p></p>

Categories