Testing email sending locally

Enonic version: 6.5.1
OS: OSX

I’m creating a new app, and I need to test sending email locally.

When I use the lib-email lib, and use the libMail.send(msg) function, I get this error:

02:24:46.750 WARN  c.enonic.xp.lib.mail.SendMailHandler - Mail could not be sent
com.enonic.xp.mail.MailException: Could not connect to SMTP host: localhost, port: 25
	at com.enonic.xp.mail.impl.MailServiceImpl.handleException(MailServiceImpl.java:66) ~[na:na]
	at com.enonic.xp.mail.impl.MailServiceImpl.send(MailServiceImpl.java:54) ~[na:na]
	at com.enonic.xp.lib.mail.SendMailHandler.send(SendMailHandler.java:117) ~[null:na]

How do I set up my dev environment to send email on OSX?

You should configure it in $XP_HOME/config/com.enonic.xp.mail.cfg

“localhost” and 25 are the default values for the mail server.

More details in the Operations Guide doc.

I set mine up to work with Gmail.

smtpHost=smtp.gmail.com
smtpPort=587
smtpAuth=true
[email protected]
smtpPassword= Not your login password. You have to set up a gmail app and get the api key.
smtpTLS=true

Before I figured this out, I actually made a MailGun app for sending email from localhost.

2 Likes

Ah, clever :slight_smile: I’ll try it out!