[1.2.4] Customized MVC Mailer and Mail hooks

203 views
Skip to first unread message

Ahmet Alp Balkan

unread,
Dec 13, 2011, 4:07:21 AM12/13/11
to play-fr...@googlegroups.com
Hello folks. I am planning to use mvc Mailer. It is a great idea, however I'm having problems with customizing it.

What I want to do is to create my own mail sender in addition to stamp sender. For instance, I'd like to save all mails sent (incl. headers and body) to the database. I am looking for my way around this however could not find anything that can do the trick, yet.

The trick should be able to get the prepared (populated) template and save it to the database with other mail parameters. I somehow need to override or prepare a proxy for play.libs.Mail, however it does not seem like we can put a hook there without changing Play source and modifying source code?

Is there a way to set a custom mailer or override play.libs.Mail.Mock class?

Kindly regards.

--
Ahmet Alp Balkan

Message has been deleted

Ahmet Alp Balkan

unread,
Dec 13, 2011, 4:11:28 AM12/13/11
to play-fr...@googlegroups.com
(correction: stamp --> SMTP)
Message has been deleted

Ahmet Alp Balkan

unread,
Dec 25, 2011, 10:32:49 AM12/25/11
to play-fr...@googlegroups.com
Hello again, I just wanted to get a bump on this topic. Any ideas how to achieve that? Thanks.

Roman R

unread,
Aug 1, 2012, 1:41:52 PM8/1/12
to play-fr...@googlegroups.com
I am interested in this as well. Did you find a solution?
It looks like you need to somehow override play.libs.Mail.send()

Marcel Klemenz

unread,
Aug 1, 2012, 2:14:48 PM8/1/12
to play-fr...@googlegroups.com
Try PlayPlugin.class and Enhancer.class.

Any major customization won't work.
I think you need to write an own mailer, but you will loose LocalVariableNamesSupport. (you cannot use this in your own classes)

If you write your own mailer you can use the groovy implementation of Template.class to load a template from a string, set the variables and render it internatlly. Then you can save the rendered Mail to db or to a file, system out or send the mail.

Roman R

unread,
Aug 2, 2012, 5:18:04 AM8/2/12
to play-fr...@googlegroups.com
My case may be simpler. What I am trying to achieve is to send certain email messages using different SMTP server.
How can I override Mailer.send()?

Marcel Klemenz

unread,
Aug 2, 2012, 5:26:38 AM8/2/12
to play-fr...@googlegroups.com
Yes and no,
You can write a Class that extends Mailer.class, but you will loos LocalVariableNameSupport
(the ability to write "send(var1, var2, otherVar)" and have the variables the template)

There was a thread 2 or 3 weeks ago about the same topic. please search it.
Reply all
Reply to author
Forward
0 new messages