Sending e-mail with Amazon SES

1,056 views
Skip to first unread message

Jonathan Leibiusky

unread,
Feb 2, 2011, 10:52:09 PM2/2/11
to play-fr...@googlegroups.com
Hi! I'm trying to use Amazon SES in Play!
I read Amazon SES Specs and there is a special Transport to be able to use it with JavaMail.

So I added the following configuration to application.conf file: mail.transport.protocol=aws
But it seems like Play! ignores this configuration and always override with smtp.

Anyone with luck doing the same thing? Am I wrong and I missed something in the configuration?

Setting mail.debug=true shows:
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]

So the problems seems to be that for some reason setting protocol to aws is not doing anything.

Thanks!

Jonathan

Riyad

unread,
Feb 3, 2011, 2:33:43 PM2/3/11
to play-framework
Jonathan,

I actually ran down this problem here:
http://groups.google.com/group/play-framework/browse_thread/thread/494eee70c012e72e/af8e2c151ab8bf23?lnk=gst&q=javamail#af8e2c151ab8bf23

The issue is that (by accident) the Amazon AWS SDK ships a META-INF/
javamail.address.map file that remaps AWS SES transport to 'smtp'
which is why you are seeing that. The correction is to remove that
address map file then requesting AWS should work as advertised instead
of getting it by default because SMTP is remapped.

I filed this issue with Amazon and they are going to remove that file
from the next SDK release.

Jonathan Leibiusky

unread,
Feb 3, 2011, 10:37:15 PM2/3/11
to play-fr...@googlegroups.com
Thanks Riyad, but I actually need to use SES and not the other way around.

Finally I got it working. It seems like Play! is hardcoding some configurations from application.conf when creating JavaMail Session.
You can see it in play.libs.Mail in getSession()
It totally ignores any configuration you might add for Amazon SES.
So what I had to do as a workaround is creating a Boostrap class that changes Session configuration in runtime like this:

@OnApplicationStart
public class Bootstrap extends Job {
    public void doJob() {
        Properties props = play.libs.Mail.getSession().getProperties();
        props.setProperty("mail.transport.protocol.rfc822","aws");
        props.setProperty("mail.aws.user", "youruser");
        props.setProperty("mail.aws.password", "yourpassword");
    }
}

Probably this is something that should be fixed in next versions of Play! so it integrates smoother with different JavaMail providers.

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


Dirk

unread,
Feb 7, 2011, 9:33:04 AM2/7/11
to play-fr...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages