Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Content E-mail as HTML

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
kena
Smarty Rookie


Joined: 29 Apr 2005
Posts: 19

PostPosted: Mon Aug 20, 2018 5:56 pm    Post subject: Content E-mail as HTML Reply with quote

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
View user's profile Send private message Send e-mail
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Aug 22, 2018 7:30 am    Post subject: Reply with quote

I don't quite understand your question. What you mean "in HTML format" ?
Back to top
View user's profile Send private message
kena
Smarty Rookie


Joined: 29 Apr 2005
Posts: 19

PostPosted: Wed Aug 22, 2018 8:27 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Aug 22, 2018 10:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Thu Aug 23, 2018 12:01 am    Post subject: Reply with quote

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
View user's profile Send private message
kena
Smarty Rookie


Joined: 29 Apr 2005
Posts: 19

PostPosted: Thu Aug 23, 2018 9:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP