On Oct 8, 1:04 pm, HAUSa <[email protected]>
wrote:
> Hi all,
>
> What is in your opinion the best way to store an e-mail template?
> In one of my actions, when an e-mail has to be sent to the user, I
> want to grab a template and replace some values.
>
Alexandru-Emil Lupu made a good suggestion. That is probably a clean
method.
When I am working on a very simple project, I tend to think Swift
might be overkill, so I just write a quick method in the actions. Not
very clean, but quick. An example:
$mailToName = $this->getRequestParameter('first_name')." ".$this-
>getRequestParameter('last_name');
$mailTo = $mailToName."<".$this->getRequestParameter
('email').">";
$mailFrom = "xxx";
$mailBody = $this->getPartial('registrationNotice', array
('username' => $this->getRequestParameter('username'), 'password' =>
$this->getRequestParameter('password')));
$subject = " New user registration ";
// 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: '.$mailTo."\r\n";
$headers .= 'From: '.$mailFrom."\r\n";
$success = mail($mailTo,
$subject,
$mailBody,
$headers);
As always, with all such decisions, it depends on the scale of the
project, how formal you need to keep the code. I wouldn't use the
above code on a project that was hoping to scale to millions of
users.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---