This is an emailing extension that wraps SwiftMailer. This extension also allows you to create emails from view files. For more information about SwiftMailer can do, see http://swiftmailer.org
Please see the phpdocs (it is in fact well-documented). First read through the main phpdoc on the Mail.php file and then the Message.php file (both in the root directory).
This is an advanced example. It is not required that you use view files to generate the emails.
$message = new YiiMailMessage; $message->view = 'registrationFollowup'; //userModel is passed to the view $message->setBody(array('userModel'=>$userModel), 'text/html'); $message->addTo($userModel->email); $message->from = Yii::app()->params['adminEmail']; Yii::app()->mail->send($message);
See Google Code hosting page
Matt Kantor has been so gracious as to provide an update, including:
Total 20 comments
check this topic
It looks like it's not possible to use a layout for outgoing mails. Is this something that will be implemented in the future?
I have a trouble with open_basedir restriction, so how can I use setCacheType() and setTempDir() methods through Yii::app()->mail ?
When transportType is set to smtp, this function works fine. But when transportType is set to php, it always returns false - even if the email is sent. Any ideas?
Two things that were nice to have:
Great extension! I've been using a old version of this one with some modifications so I can use it in Console Apps and use the addPart method of Swiftmailer.
One of the things I think is still missing in this extension is the possibility of adding alternative body using a view. So I added a method to your extension in YiiMailMessage:
So in my controller I do:
Sorry if I'm wrong somewhere but I'm no expert.
Has anyone tried using a grid view in the email template ?
I installed this extension for on project I am working on, and it works like champ. The best thing is that it supports views, so, you just simply create email folder, and place all email views/templates there. Thanks!
this solves the issue I reported in my previous comment. Sorry I should have made this one comment.
in YiiMailMessage.setBody():
I also like this extension very much! Thanks @jonah.
But one very big improvement would be for YiiMailMessage.setBody() to use the normal view-search algorithm, including looking for localized versions of the view. I am emailing to people in various languages. I know the language of my recipient and want to send them an email in their own language.
Great extension and somehow easy to implement. Unfortunately I have a problem with 'setFrom' properly. Well, I can set an email and name but on the other side (gmail) the email won't appear... e.g.
then, in gmail
Why does 'email_to' appear as from email? Does that make any sense? Am I overseeing something obvious?
Thanks for help and advice! DF
especially for a localhost setup. Thanks!
Gentlemen, how can I use views and view variable? I need to develop couple of email templates and use this extension any ideas? Thanks in advance
Great component :) Although it took a little razzle fracking to realise the transportType must be lower case - d'oh!
Here's a sample set up for using gmail or google apps:
Download mail to protected/extensions/yii-mail in your application. (some of the examples use /mail instead of /yii-mail - just ensure they are consistent)
In protected/main/config.php
Then to test its all working, I amended the Contact action in /protected/controllers/siteController.php
If you want to use a different transport service within the app then use:
To set STMP, put this code under the 'components' part in your main.php in config folder. Assume you put this extension under /protects/extensions/mail/.
Very well... you should have idea how to set it, hope it helps. For transport options, you should look in the document for more.
If you are using setBcc() only without addTo(), then line YiiMail.php(189) fails:
it should at least be:
I want to know hot to config a SMTP server(Support servers that require username & password and/or encryption). Who can do me a favor, THX?
I have ended up making a class the extends YiiMail that overwrites getTransport so that it uses system parameters in the main config to determine which SMTP mail server to connect to. It works well, but I'm just wondering why this isn't in the extension or have I missed something?
Does this extension support themes?
Hi!
How Can I (or where) insert extra headers to the message?? cuz when I send a mail to xxx@hotmail.com the mail appears into the junk box
Regards
Leave a comment
Please login to leave your comment.