Page 1 of 1

[solved] How to setup Exim for SendGrid?

Posted: Thu Jul 16, 2015 11:56 pm
by travelback
Hi, I'm trying to get Exim to forward smtp traffic to SendGrid. I feel that I'm close, but must be missing a step. The server is hosted on GCE which adds a small layer of complication since port 25 outbound is blocked.

Here are some notes:

I'm using this document for setup: https://sendgrid.com/docs/Integrate/Mai ... /exim.html

SendGrid is working if I connect my (Thunderbird) client directly to it, but I can't forward emails through the email server to SendGrid

if I run exim -bt [email] I get back:
router = send_via_sendgrid, transport = sendgrid_smtp
host smtp.sendgrid.net [108.168.190.108] port=2525
host smtp.sendgrid.net [208.43.76.146] port=2525
host smtp.sendgrid.net [208.43.76.147] port=2525

I can also telnet 2525 from my server to SendGrid

If I run exim -ql -v [email] I get back:
[email] R=send_via_sendgrid T=sendgrid_smtp defer (-54): remote deliveries suppressed
delivering 1ZFsMP-0004aC-54 (queue run pid 20895)

I think there is my problem. My emails bound for remote delivery are in the local queue. When I followed the tutorial I only added to the exim configuration, but didn't change or remove anything from default. Is that something I have to do? any guidance is appreciated.

I'm running Ubuntu Server 14.04 on Google Cloud. I can post configs if helpful.

Re: How to setup Exim for SendGrid

Posted: Fri Jul 17, 2015 3:59 am
by travelback
I got it to work by creating a folder called localdomains

and setting exim4.conf.template to:

domainlist local_domains = dsearch;/etc/exim4/localdomains/
domainlist relay_to_domains = dsearch;/etc/exim4/localdomains/

Re: [solved] How to setup Exim for SendGrid?

Posted: Thu Aug 13, 2015 10:46 am
by minhnhat
Hi travelback

I'm using GCE too, and face the same problem.

Could you explain more details, such as what i need to do to config exim to send email via Sendgrid. Before install vestacp, postfix send email ok. After install vestacp, exim & configuration of vestacp changed postfix (i guest that).

Please help me, thank you!

[update] i'm using centos 6.6 64bit

Re: [solved] How to setup Exim for SendGrid?

Posted: Fri Aug 14, 2015 1:16 am
by travelback
minhnhat wrote:Hi travelback

I'm using GCE too, and face the same problem.

Could you explain more details, such as what i need to do to config exim to send email via Sendgrid. Before install vestacp, postfix send email ok. After install vestacp, exim & configuration of vestacp changed postfix (i guest that).

Please help me, thank you!

[update] i'm using centos 6.6 64bit
Since you are using Cent I might have some of the commands wrong, but try this:

# navigate to you exim folder
cd /etc/exim

# create an empty directory
mkdir localdomains

# create a backup of your config file
cp exim4.conf.template exim4.conf.template.original

# edit your /etc/exim/exim.conf file and change the following lines

# From:
domainlist local_domains = dsearch;/etc/exim/domains/
domainlist relay_to_domains = dsearch;/etc/exim/domains/

# To:
domainlist local_domains = dsearch;/etc/exim/localdomains/
domainlist relay_to_domains = dsearch;/etc/exim/localdomains/

In my case whatever was in the domains folder was considered local and would not be forwarded to SendGrid. You could just delete whats in the domains folder, but when you add a new user/domain you will have to remember to delete it.