Feb 012016

I recently configured my cPanel/Exim installation to relay mail through SendGrid, using┬áSendGrid’s official documentation┬áand this page to supplement it.

After some tweaking, everything worked as expected, but I was left with one problem: I have scripted emails that include some large (>20 MB) attachments, and SendGrid does not support attachments of that size.

These emails are sent to a single domain, and I have no issue sending them directly, so I configured Exim (through WHM’s┬áService Configuration -> Exim Configuration Manager -> Advanced Editor) to send messages to that one domain without going through the SMTP relay, while keeping the relay as the default mail transport.

To do this, edit the┬áPREROUTERS section of your Exim configuration file. ┬áBefore the relay transport block, typically “send_via_sendgrid” for SendGrid, insert the following lines:

  driver = dnslookup
  domains = example.com
  transport = remote_smtp 

You’ll want to update the router name (“to_example”) and the domain to suit your needs. It is very important to place this above the SendGrid router block, because order matters! ┬áThis code tells Exim that if the message is destined for “example.com”, that it should utilize the “remote_smtp” transport.

Any domains that┬ádon’t match this rule will continue down to the SendGrid transport code, so they will relay as expected.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>