[symfony-users] Re: Best way for e-mail templates

2009-10-08 Thread Jake Barnes


This issue has come up before. I think someone suggested have a module
just for the emails. Seems like a good idea.


On Oct 8, 3:19 pm, HAUSa 
wrote:
> Ok, thx Alex, but I prefer not to use the database for this. In my
> opinion, the DB is only ment for user generated content storage.
>
> Martin, your answer is not a solution to my problem. You use $body =
> "the body", so my question still remains. Where do I leave the HTML e-
> mail template? I don't want to paste that whole code in the action.
>
> On 8 okt, 20:41, Martin Ibarra Cervantes 
> wrote:
>
>
>
> > hi, i use swift
>
> > $transport = 
> > Swift_SmtpTransport::newInstance(sfConfig::get('app_correo_hostname'),sfCon 
> > fig::get('app_correo_puerto'))
> >                         ->setUsername(sfConfig::get('app_correo_usuario'))
> >                         ->setPassword(sfConfig::get('app_correo_password')) 
> > ;
>
> >                 $mailer = Swift_Mailer::newInstance($transport);        
> >                 $body = "the body";          
> >                 $subject = "Validacion de Cuenta, Mis Retratos.";
> >                 $message   = Swift_Message::newInstance($subject)
> >                 ->setFrom(array(sfConfig::get('app_correo_usuario', 'Mis 
> > Retratos')))
> >                 ->setTo(array($this->form->getValue('correo')))        
> >                 ->setBody($body);
> >                 $mailer->send($message);            
> > its very single.
>
> > On Thu, Oct 8, 2009 at 10:41 AM, Alexandru-Emil Lupu
>
> >  wrote:
> > > What i have done was to implement swift mailer, create a component that
> > > handles the emails and parser, and all the email templates stored into
> > > database as
>
> > > Subject, Html, plain ...
>
> > > Unfortunatelly, I cannot reveal the code ...
> > > Alecs
>
> > > On Thu, Oct 8, 2009 at 8:04 PM, HAUSa
> > >  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.
>
> > >> My idea is to create a module called "emails" and use the template
> > >> folder, but maybe there is a less dirty method?
>
> > >> Thanks!
>
> > > --
> > > As programmers create bigger & better idiot proof programs, so the 
> > > universe
> > > creates bigger & better idiots!
> > > I am on web:  http://www.alecslupu.ro/
> > > I am on twitter:http://twitter.com/alecslupu
> > > I am on linkedIn:http://www.linkedin.com/in/alecslupu
> > > Tel: (+4)0748.543.798
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Best way for e-mail templates

2009-10-08 Thread Jake Barnes



On Oct 8, 1:04 pm, HAUSa 
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 symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Best way for e-mail templates

2009-10-08 Thread MDrollette

I think you have the right idea with the solution you mention.

For me, I store all my email templates as partials in the templates
directory of the module they are used in. Then in the action, using
Swift mailer, I simply do something like:

$mailContext = array('name' => $user->getFirstname());
$message->addPart($this->getPartial('registration/htmlWelcomeEmail',
$mailContext), 'text/html');

On Oct 8, 1:04 pm, HAUSa 
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.
>
> My idea is to create a module called "emails" and use the template
> folder, but maybe there is a less dirty method?
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Best way for e-mail templates

2009-10-08 Thread HAUSa

Ok, thx Alex, but I prefer not to use the database for this. In my
opinion, the DB is only ment for user generated content storage.

Martin, your answer is not a solution to my problem. You use $body =
"the body", so my question still remains. Where do I leave the HTML e-
mail template? I don't want to paste that whole code in the action.

On 8 okt, 20:41, Martin Ibarra Cervantes 
wrote:
> hi, i use swift
>
> $transport = 
> Swift_SmtpTransport::newInstance(sfConfig::get('app_correo_hostname'),sfConfig::get('app_correo_puerto'))
>                         ->setUsername(sfConfig::get('app_correo_usuario'))
>                         ->setPassword(sfConfig::get('app_correo_password')) ;
>
>                 $mailer = Swift_Mailer::newInstance($transport);        
>                 $body = "the body";          
>                 $subject = "Validacion de Cuenta, Mis Retratos.";
>                 $message   = Swift_Message::newInstance($subject)
>                 ->setFrom(array(sfConfig::get('app_correo_usuario', 'Mis 
> Retratos')))
>                 ->setTo(array($this->form->getValue('correo')))        
>                 ->setBody($body);
>                 $mailer->send($message);            
> its very single.
>
> On Thu, Oct 8, 2009 at 10:41 AM, Alexandru-Emil Lupu
>
>  wrote:
> > What i have done was to implement swift mailer, create a component that
> > handles the emails and parser, and all the email templates stored into
> > database as
>
> > Subject, Html, plain ...
>
> > Unfortunatelly, I cannot reveal the code ...
> > Alecs
>
> > On Thu, Oct 8, 2009 at 8:04 PM, HAUSa
> >  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.
>
> >> My idea is to create a module called "emails" and use the template
> >> folder, but maybe there is a less dirty method?
>
> >> Thanks!
>
> > --
> > As programmers create bigger & better idiot proof programs, so the universe
> > creates bigger & better idiots!
> > I am on web:  http://www.alecslupu.ro/
> > I am on twitter:http://twitter.com/alecslupu
> > I am on linkedIn:http://www.linkedin.com/in/alecslupu
> > Tel: (+4)0748.543.798
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Best way for e-mail templates

2009-10-08 Thread Martin Ibarra Cervantes

hi, i use swift

$transport = 
Swift_SmtpTransport::newInstance(sfConfig::get('app_correo_hostname'),sfConfig::get('app_correo_puerto'))
->setUsername(sfConfig::get('app_correo_usuario'))
->setPassword(sfConfig::get('app_correo_password')) ;

$mailer = Swift_Mailer::newInstance($transport);
$body = "the body"; 
$subject = "Validacion de Cuenta, Mis Retratos.";
$message   = Swift_Message::newInstance($subject)
->setFrom(array(sfConfig::get('app_correo_usuario', 'Mis 
Retratos')))
->setTo(array($this->form->getValue('correo'))) 
->setBody($body);
$mailer->send($message);
its very single.


On Thu, Oct 8, 2009 at 10:41 AM, Alexandru-Emil Lupu
 wrote:
> What i have done was to implement swift mailer, create a component that
> handles the emails and parser, and all the email templates stored into
> database as
>
> Subject, Html, plain ...
>
> Unfortunatelly, I cannot reveal the code ...
> Alecs
>
>
> On Thu, Oct 8, 2009 at 8:04 PM, HAUSa
>  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.
>>
>> My idea is to create a module called "emails" and use the template
>> folder, but maybe there is a less dirty method?
>>
>> Thanks!
>>
>
>
>
> --
> As programmers create bigger & better idiot proof programs, so the universe
> creates bigger & better idiots!
> I am on web:  http://www.alecslupu.ro/
> I am on twitter: http://twitter.com/alecslupu
> I am on linkedIn: http://www.linkedin.com/in/alecslupu
> Tel: (+4)0748.543.798
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Best way for e-mail templates

2009-10-08 Thread Alexandru-Emil Lupu
What i have done was to implement swift mailer, create a component that
handles the emails and parser, and all the email templates stored into
database as

Subject, Html, plain ...

Unfortunatelly, I cannot reveal the code ...
Alecs


On Thu, Oct 8, 2009 at 8:04 PM, HAUSa <
jeroen_heeft_behoefte_aan_r...@hotmail.com> 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.
>
> My idea is to create a module called "emails" and use the template
> folder, but maybe there is a less dirty method?
>
> Thanks!
> >
>


-- 
As programmers create bigger & better idiot proof programs, so the universe
creates bigger & better idiots!
I am on web:  http://www.alecslupu.ro/
I am on twitter: http://twitter.com/alecslupu
I am on linkedIn: http://www.linkedin.com/in/alecslupu
Tel: (+4)0748.543.798

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---