How to configure HestiaCP / Exim 4 for SMTP Relay (SendGrid, Mailgun, Amazon SES, etc)

Hi Guys,

I would like to use Sendgrid to relay all emails from the server and have followed the below

Sadly the configuration file update-exim4.conf.conf doesn’t seem to be included on loading the service and mail is still being delivered directly from the server.

I’ve been through a number of posts on the VestaCP forums which seem to refer to a different implementation of Exim.

Does anyone have this working? Thanks for your time.

I’ve figured this out for mailgun. You probably want to be editing exim4.conf.template

Under ‘begin authenticators’ I added

mailjet_login:
  driver = plaintext
  public_name = LOGIN
  client_send =:apiuser:apikey

Under ‘begin routers’ I added

 send_via_mailjet:
   driver = manualroute
   domains = ! +local_domains
   transport = mailjet_smtp
   route_list = * in-v3.mailjet.com

// This sends all non-local domains through mailjet. You can add specific domains if you want. The route_list is the name of the mailjet server I’m sending through.

Under ‘begin transports’ I have

mailjet_smtp:
  driver = smtp
  port = 587
  hosts_require_auth = *
  hosts_require_tls = *

That was pretty much it. Chang the port as neccessary. Put your real apiuser and apikey in between the colons

2 Likes

Thank you for your help.

I carried out the following to get it working with sendgrid

Under ‘begin authenticators’ I added

sendgrid_login:
  driver = plaintext
  public_name = LOGIN
  client_send = : apikey : key

Note: username should actually be ‘apikey’, not your sendgrid username

Under ‘begin routers’ I added

send_via_sendgrid: 
  driver = manualroute
  domains = ! +local_domains
  transport = sendgrid_smtp
  route_list = "* smtp.sendgrid.net::587 byname"
  host_find_failed = defer
  no_more

Under ‘begin transports’ I added

sendgrid_smtp: 
  driver = smtp
  hosts = smtp.sendgrid.net
  hosts_require_auth = <; $host_address
  hosts_require_tls = <; $host_address

Under router configuration for alias and catchall I also changed:

redirect_router = dnslookup

to:

redirect_router = send_via_sendgrid
1 Like

hey guys, thanks a lot for sharing, I am sure this is helpful for other community members as well!

going to add infos about using amazon SES here as well:

Under ‘begin authenticators’ I added

ses_login:
driver = plaintext
public_name = LOGIN
client_send = : user : password

Under ‘begin routers’ I added

send_via_ses:
driver = manualroute
domains = ! +local_domains
transport = ses_smtp
route_list = * email-smtp…amazonaws.com;

Under ‘begin transports’ I have

ses_smtp:
driver = smtp
port = 587
hosts_require_auth = *
hosts_require_tls = *

as one can see it’s pretty much the same, external aws guide here: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-exim.html

keep in mind that the domains usually need to be verified within your mail relay service first, also the simple configuration above is used for all domains, so if you want to have it more specific - change as needed (and maybe report back) :wink:

1 Like