Using Mailgun to Send Emails from your Website

Mailgun’s SMTP Relay service is a quick an easy way to have ExpressionEngine transactional emails handled through a dedicated email provider. There’s just one tiny glitch you need to be aware of. The line ending setting needs to be changed from the default \n to \r\n. That’s it. Everything else is self-evident. But in case it’s not…

In your Mailgun account, go to the Overview for your domain. In my case, I just have their default sandbox domain. You’re going to select ‘SMTP’ as your mail option and the required settings, including username and password, will be revealed.

Go to your ‘Settings- Outgoing Email’ settings in your ExpressionEngine control panel and enter your Mailgun settings

Setting Value
Protocal SMTP
Newline Character \r\n
Server Address smtp.mailgun.org
Server Port 587
Connection Type STARTTLS

Save your settings and send a few test emails from the Communicate page.

Robin Sowell's avatar
Robin Sowell

Robin got involved with EllisLab in 2002, using pMachine Pro to build a personal site. Since then, her casual interest has grown into an obsession and she enjoys nothing more than seeing what new…

Comments 2

April 16, 2021

harthouse

Hi Robin, Thanks for the article. May I send email marketing campaigns with this method? If not, how can I send email campaigns within ee with the custom HTML email templates? Thanks, Chris

May 3, 2021

Robin Sowell

No, ExpressionEngine removed the mailing list module quite a while back, as we decided that this was something much better handled by software that specializes in email- such as mailgun.

So- Mailgun to handle your mailing list? Good option. EE to manage the list and send via Mailgun API? Better to do it all in Mailgun (or your choice of service).

> how can I send email campaigns within ee with the custom HTML email templates?

I wouldn’t. I’d have a sign up form where they can sign up for your newsletter/mailing list/etc. But I’d handle the mail aspects outside of ExpressionEngine.