Sending Email from PHP using Templates

Monday, May 2nd, 2011|Beginner tips, Version 4|by Romans

Agile Toolkit bundles a powerful emailing class. However instead of focusing on adding SMTP support and related features (which are rarely used in live environment anyway) this class focuses on use of Mail Templates and simplifying email sending in general.

[php]
$mail=$this->add(‘TMail’);
$mail->loadTemplate(‘test-mail’);
$mail->setTag(‘name’,'John’);
$mail->setTag(‘product’,'VAC-293′);
$mail->setTag(‘link’,$this->api
->getDestinationURL(‘./register’,array(‘code’=>’123′))
    ->useAbsoluteURL());
$mail->send($email);
[/php]

See this code in action:

http://codepad.agiletoolkit.org/tmail

3 Comments

Romans
Posted May 2, 20111:02 pm

There are actually many other powerful features such as HTML templates. I’ll highlight them some other time.

Trevor North
Posted June 22, 20127:48 am

Hi Romans

Appreciate you are busy with v4.2 but in Tmail.php, it mentions an example of a mail template can be found in kt2 directory but this no longer exists. The codepad example above is not found and i cant find any example in the documentation or the raw code of a plain text and html email template for Tmail.

Thanks in advance
Trevor

Romans
Posted June 24, 20128:32 am

It’s been a while, Trevor!

Here is working example: http://agiletoolkit.org/codepad/contact