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>
➛<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>
Related
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");
I try to send an email from my web site, I received email but not support HTML.
Here is my code:-
////////
$headers = "From: $email\n" . "Reply-To: $email\n";
$headers .= "Register: Super market\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";
//$header = "From: $email\n" . "Reply-To: $email\n";
$subject = "Register in Super market";
$email_to = EMAIL;
$emailMessage = "<b>NO :</b> " . $aid."\n";
$emailMessage .= "<b>Name :</b> " . $firstname.' '.$fathername.' '.$familyname. "\n";
$emailMessage .= "<b>Tell :</b> " . $tell . "\n\n";
$emailMessage .= "<b>Fax :</b> " . $fax . "\n\n";
$emailMessage .= "<b>Email :</b> " . $email . "\n\n";
//use php's mail function to send the email
#mail($email_to, $subject ,$emailMessage ,$headers );
Update:
Hi every one.
I set an question here and solved successful
But now i need to add some file as attachment.
So, I have 2 variable, That save the file upload into DB like this:-
$filenameword
$filenamezip
How can set this tow variable as file attachment in email inbox.
////////
$headers = "From: $email\n" . "Reply-To: $email\n"; // See the s at the end of $headers
$headers .= "Register: Super market\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";
//$header = "From: $email\n" . "Reply-To: $email\n";
$subject = "Register in Super market";
$email_to = EMAIL;
$emailMessage = "<b>NO :</b> " . $aid."\n";
$emailMessage .= "<b>Name :</b> " . $firstname.' '.$fathername.' '.$familyname. "\n";
$emailMessage .= "<b>Tell :</b> " . $tell . "\n\n";
$emailMessage .= "<b>Fax :</b> " . $fax . "\n\n";
$emailMessage .= "<b>Email :</b> " . $email . "\n\n";
//use php's mail function to send the email
mail($email_to, $subject ,$emailMessage ,$headers );
You have a typo in your code.
You are assigning header strings to $headers but you're passing $header to the mail function.
Also please no # before functions. It's a bad practice.
////////
$headers = "From: $email\n" . "Reply-To: $email\n"; // See the s at the end of $headers
$headers .= "Register: Super market\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";
//$header = "From: $email\n" . "Reply-To: $email\n";
$subject = "Register in Super market";
$email_to = EMAIL;
$emailMessage = "<b>NO :</b> " . $aid."\n";
$emailMessage .= "<b>Name :</b> " . $firstname.' '.$fathername.' '.$familyname. "\n";
$emailMessage .= "<b>Tell :</b> " . $tell . "\n\n";
$emailMessage .= "<b>Fax :</b> " . $fax . "\n\n";
$emailMessage .= "<b>Email :</b> " . $email . "\n\n";
//use php's mail function to send the email
mail($email_to, $subject ,$emailMessage ,$headers ); // See the s at the end of $headers
So I have the script sending a multipart email of plain text and html, some reason the plaintext version is not working, but I can see that it is sending when I show original in gmail. It just shows the html though when I click message garbled?
// headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= 'From: From Name <'. FROM_EMAIL. ">\r\n";
$headers .= 'To: '.$member->member_info['memem']. "\r\n";
$headers .= 'Bcc: receipts#gmail.com' . "\r\n";
$headers .= "Subject: Registration Receipt\r\n";
$headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";
// Additional headers
$message . "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/plain;charset=utf-8\r\n\r\n";
$message .= $receipt_txt;//plain text
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/html;charset=utf-8\r\n\r\n";
$message .= $receipt_html;//html
$message .= "\r\n\r\n--" . $boundary . "--";
mail( $member->member_info['memem'], 'Registration Receipt', $message, $headers );
Crap. I found it. "$message . "\r\n\r\n--" . $boundary . "\r\n";" should be "$message .= "\r\n\r\n--" . $boundary . "\r\n";" I feel dumb :(
So the issue is I want multiple recipients for my PHP form.
What happens is the site user enters there email and then another email for another peroson (for example there doctor).
So what I need is the the doctor to be emailed to.
This is what I am using to know success
$mail_to = $field_emaildoc .$field_email;
This doesent seem to work?
Any ideas would be great :)
Thanks
one option is to add a "Cc" to your header:
$sender_email = 'email#domain.com';
$sender_name = 'YOUR NAME';
$send_to = 'email#domain.com';
$send_to_copy = 'anotheremail#domain.com';
$message = 'THIS IS YOUR MESSAGE';
$subject = 'THIS IS YOUR SUBJECT';
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= "From: $sender_name<" . $sender_email . ">" . "\r\n";
$headers .= "X-Sender: $sender_name<" . $sender_email . ">" . "\n";
$headers .= "X-Mailer: PHP " . phpversion() . "\n";
$headers .= "X-Priority: 3" . "\n";
$headers .= "X-Sender-IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
$headers .= "Return-Path: $sender_name<" . $sender_email . ">" . "\r\n";
$headers .= "Reply-To: $sender_name<" . $sender_email . ">" . "\r\n";
$headers .= "Cc: $send_to_copy" . "\r\n";
mail($send_to,$subject,$message,$headers);
The problem with this, is that the person receiving the email can see who was copied in. An alternative would be to use: "Bcc" instead of "Cc" or just use the mail() function twice and remove the "Cc" or "Bcc":
mail($send_to1,$subject,$message,$headers);
mail($send_to2,$subject,$message,$headers);
You should put comma between mail addresses . Look explanation of to parameter, here : http://php.net/manual/en/function.mail.php
You'll need a comma:
$mail_to = $field_emaildoc . ',' . $field_email;
Use the default mail function from PHP.
The recipients are devided by a Comma.
When you want CC and BCC you can set the header. Example from PHP.net:
$header .= 'To: Simone <simone#example.com>, Andreas <andreas#example.com>' . "\r\n";
$header .= 'From: Geburtstags-Erinnerungen <geburtstag#example.com>' . "\r\n";
$header .= 'Cc: geburtstagsarchiv#example.com' . "\r\n";
$header .= 'Bcc: geburtstagscheck#example.com' . "\r\n";
mail($empfaenger, $betreff, $nachricht, $header);
I am working on an HTML page where i need to send confirmation by HTML email using PHP.
I don't have much experience in PHP as i occasionally work on PHP.
I am able to send the HTML email using PHP and it comes up nice except the IMAGE part.
I have checked about 30 example and implement different ways of but non works.
When i check the source code of email it shows image part as
<img src="http://www.xyz.com/images/emailheader.jpg\"">
<img src="http://www.xyz.com/images/emailheader.jpg\";" alt="mage"">
Code for HTML
$subject = 'Confirmation';
$message = '<table ><tr><td><img src=\"http://www.xyz.com/images/emailheader.jpg\" /></td></tr><tr><td >'. "\r\n";
$message .= '<img src=\"http://www.xyz.com/images/emailheader.jpg\"; alt="Image" />';
$message .= 'Title <br/><br/>'. "\r\n";
$message .= 'Dear '. $_SESSION['FN'] . ' '.$_SESSION['LN'].'<br/><br/>'. "\r\n";
$message .= ' <br/><br/>'. "\r\n";
$message .= 'Name: '. $_SESSION['FN'] . ' '.$_SESSION['LN'].'<br/>'. "\r\n";
$message .= 'Email: '. $_SESSION['Email'].'<br/>'. "\r\n";
$message .= '<br/><br/>.'. "\r\n";
$message .= '<br/><br/>Best Regards,'. "\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: booking#xyz.com' . "\r\n";
$headers .= 'Reply-To: abc#xyz.com' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
ini_set ( "SMTP", "smtp.abc.com" );
I would appreciate if some can correct my code or at-least tell me what i am doing wrong
problem is in this line:
'<img src=\"http://www.alfarooqcentre.com/images/emailheader.jpg\"; alt="Image" />';
remove "\" and ";"
or check this tutorial, there is what you want.
http://phpform.net/html_mail.php