|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
kena Smarty Rookie
Joined: 29 Apr 2005 Posts: 19
|
Posted: Mon Aug 20, 2018 5:56 pm Post subject: Content E-mail as HTML |
|
|
Hi,
I use the following code to send an e-mail:
[php]
Code: |
$smarty->assign('name', $_POST['name']);
$smarty->assign('email', $_POST['email']);
$smarty->assign('subject', $_POST['subject']);
$smarty->assign('content', $_POST['content']);
mail($globals['email'], $_POST['subject'], $smarty->fetch('form_body.tpl'), 'From: Our website <' .$globals['email']. '>', '-f ' .$globals['email']. '');
|
[template]
Code: |
Dear webmaster,
{$name} has contacted us through our webste. Here's the message::
Name: {$name}
E-mail address: {$email}
Subject: {$subject}
Content:
{$content}
*******************************
This e-mail message is intended exclusively for the addressee. If the e-mail was sent to you by mistake, please return it to us.
*******************************
|
How do I get {$content} in HTML format? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Aug 22, 2018 7:30 am Post subject: |
|
|
I don't quite understand your question. What you mean "in HTML format" ? |
|
Back to top |
|
kena Smarty Rookie
Joined: 29 Apr 2005 Posts: 19
|
Posted: Wed Aug 22, 2018 8:27 pm Post subject: |
|
|
AnrDaemon wrote: | I don't quite understand your question. What you mean "in HTML format" ? | The content of my e-mail gives the HTML code. Fot instance <b>test</b> in stead of setting test in bold. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Aug 22, 2018 10:16 pm Post subject: |
|
|
Of course. You're sending your message as plain text. Worse still, you're sending it as unsafe plain text. The mail() function does not do any encoding of the message body.
You have to, either, learn [RFC 2045] and manually properly encode your message, or use one of the mail sending libraries out there, like PHPMailer or SwiftMailer, or what else. |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Thu Aug 23, 2018 12:01 am Post subject: |
|
|
Smarty is not a problem in this situation.
Example #5 here:
http://docs.php.net/manual/en/function.mail.php
details what you need to pass to the mail() function to indicate to the recipient's email program it should display the message as an HTML web page would. |
|
Back to top |
|
kena Smarty Rookie
Joined: 29 Apr 2005 Posts: 19
|
Posted: Thu Aug 23, 2018 9:16 pm Post subject: |
|
|
bsmither wrote: | Smarty is not a problem in this situation. | You're absolutely right. I've done some digging and found the issue was just PHP mail() header settings. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|