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";
Related
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);
So I have a question that some more experienced individuals may be able to shed some light on and steer me in the correct direction. Here is what I have and what I am trying to do.
I have tinymce up and working just fine on a php webpage, of course that is until I go to submit it.
I am trying to use tinymce as the text editor for an email body that I am inserting into a vbscript then calling wsh to execute the .vbs. Everything works fine when I really don't edit the text. Just typing in and submitting without any colored text or other formatting.
However, if I do anything to the text at all it causes the .vbs not to execute. Upon opening up the unexecuted file I see that the "#" character for example when tinymce inserts the span color is causing it to hang.
I have googled and not found this issue presented is there something that I am missing? Or is there a better way to go about sending html emails from a webpage based text editor?
As I said as long as I don't really want to edit the text it works but I could do that plainly with a simple textarea but that defeats the purpose of wanting to be able to produce formatted emails.
Any and all suggestions are greatly appreciated. Thank you in advance for your time and help.
E-Mail Example:
// Sending an email with PHP
$to = $email; // Send email to our user
$subject = 'Email Sent with PHP'; // Give the email a subject
$message = '
<html>
<head>
</head><body>
<h3>Hey!</h3>
</body>
</html>
'; // Our message above including the link
$headers = 'From:nobody#nowhere.com' . "\r\n"; // Set from headers
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers); // Send our email
I'm newbie to PHP, HTML and to programming at all.
I'm trying to create a contact form with PHP and HTML.
Everything is working fine, and i'm able to get the e-mails.
Except of one thing, If i'm trying to fill the form with another language, In my case it's hebrew, The mail i'm getting is with gibrish.
I saved the html file with the UTF-8 encoding, and i added the meta code. checked my outlook encoding and checked the mails i'm getting with a webinteface and it's still gibrish.
Any ideas?
First of all, try to "Echo" the content of the email to the browser instead of sending it out.
If it displays correctly, you are fine on the website part.
If the text is coming from a POST or GET form, you might need to convert it
with htmlspecialchars_decode(), see
http://www.php.net/manual/en/function.htmlspecialchars-decode.php
Then you can take care about the format of the email.
If you are sending email, you need to set the proper headers for the email just as you do for the website. For UTF-8, you would do:
$headers = "From: ExRobot <robot#example.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .="Content-Transfer-Encoding: 8bit";
If your subject also might include foreign languages you can set it to
"=?utf-8?B?".base64_encode($subject)."?="
If this does not help, post a complete sample email here as you get it. this will help a lot to understand what is wrong.
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);
I have a php file that I am trying to send the output in a email using the php mail function (PHPMailer is not an option as the server I am working restricts their SMTP server). The code for the mail function is
$to = "xxx#example.com";
$subject = "Outdoor Grill Service Request";
ob_start();
require 'grill-form.php';
$body = ob_get_clean();
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers = "From: xxx#example.com\n";
mail($to,$subject,$body,$headers);
echo "Mail sent to $to";
grill-form.php is a php file that contains a html file that has tables that are populated with php variable from a form. This worked perfectly using PHPMailer but once I migrated over to standard php mail is got "screwy".
The issue I am running into is when the email sends I am getting raw HTML code and not the output of the grill-form.php (a styled table with values). I have little knowledge with the php mail function so I might be missing something stupid.
Was wondering what I am doing wrong. Thank you in advance for you help you people are the best.
Assuming that's your actual code, you're overwriting the $headers variable with the third declaration, not appending to what you have. The Content-type header is never making it in.
PHPMailer does support SMTP, by the way--what exactly do you mean by "restricts their SMTP server"? (Here's an example: http://phpmailer.worxware.com/index.php?pg=examplebsmtp)