Send/Receive through external email provider

Hello all,

I am looking for some advice / kick in the right direction in regards to having your own email server vs hosting it remotely and was hoping somebody could help me out a bit.

Currently we are hosting our own email server, we are using EasyEngine and have installed the mail stack - it basically installs Postfix, Vimadmin, and some other projects and automatically sets up the email server. Everything is working great but it is not without its hiccups (currently we are actually not able to send email).

I understand the advantages/disadvantages of hosting your own email. We are expecting an increase in our email usage (company is expanding) and as the single developer I foresee that I will not be able/want to handle the email administration. Thus I want to move to a third party provided like Google Apps or 365.

Here are the requirements:

  • Use our own domain to send/receive email

  • Use contact forms on our website that send email to a specific email address associated with that contact form (not every form has the same email address).

  • Our website (wordpress) will also need to be able to send confirmation/automatic emails to our users

  • The emails from our website will come from some generic email account (eg [email protected]) but we don't need a 'send'-box for this

Basically we are trying to send and receive email through our custom domain, and allow our server to send emails to X number of email accounts.

We can use a service like 365 by properly [](setting the DNS records (1))[setting the DNS records (1)](setting the DNS records (1)), eg updating MX/CNAME etc, after that we will be able to receive and send email through 365. However I am having difficulty finding information how our server will be able to send out emails? Do I still need Postfix, what about spam-assassin etc? I have been reading quite a bit of articles and I am a bit confused to what to do..

  • Setup postfix to [](use an external SMTP (2))[use an external SMTP (2)](use an external SMTP (2)); but as far as I understand this is similar to having an email account in outlook on your PC.

  • Setup [](email forwards in postfix (3))[email forwards in postfix (3)](email forwards in postfix (3)); but we will be adding/changing the contact forms so our emails will continue to change + new users apply all the time.

  • Setup [](email notification in postfix (4))[email notification in postfix (4)](email notification in postfix (4)); this seems to be the closest to what we need but I'm a bit confused how to configure

I think I'm in the right direction, I am just looking for something more concrete in regards to how our server will look.

Thank you, hopefully this makes sense - let me know if you have any questions.

1) https://support.office.com/en-us/articl … n-US&ad=US">https://support.office.com/en-us/article/Create-DNS-records-for-Office-365-at-any-DNS-hosting-provider-7b7b075d-79f9-4e37-8a9e-fb60c1d95166?CorrelationId=2ef73818-a02d-4176-81ef-550d53936803&ui=en-US&rs=en-US&ad=US

2) https://www.linode.com/docs/email/postf … tp-debian7">https://www.linode.com/docs/email/postfix/postfix-smtp-debian7

3) http://www.binarytides.com/postfix-mail … ng-debian/">http://www.binarytides.com/postfix-mail-forwarding-debian/

4) http://www.donaldsimpson.co.uk/2011/04/ … fications/">http://www.donaldsimpson.co.uk/2011/04/29/using-postfix-for-wordpress-email-notifications/ and https://www.digitalocean.com/community/ … untu-14-04">https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04

12 Replies

You will need to use two different services for your needs:

1) An email "hosting" service that hosts all your mailboxes. You will use this to receive emails, as well as send emails manually when you need to. Google Apps and 365 are examples of this kind of service. You might also want to try some of the smaller, more specialized alternatives, such as Fastmail.

2) An email "sending" service through which all automated emails (signup confirmations, password reminders, notifications, contact forms) will be sent. Look up Mailgun, SendGrid, SparkMail, and similar services. Your emails will arrive much more reliably if you send through such a service than through your own server, because it's their job to ensure that your emails get the lowest spam score possible. They provide APIs for you to use directly in your web app, as well as SMTP relays that you can configure Postfix to forward all outgoing emails to.

Remember to set up both SPF and DKIM for both of the above. Give your MX and TXT (SPF) records short TTL values at least a day before you make the move, so that your updates will propagate as soon as possible. You don't want half the world to continue to send emails to your old MX while the other half sends to your new MX.

Disclaimer: I am not affiliated with any of the companies mentioned above.

@sleddog:

Mail originating on the server would travel like this:

Wordpress -> Local Postfix -> Remote SMTP Server (Google Apps or 365) -> Recipient

Your local postfix would be configured to relay mail to the remote smtp server, using authentication (e.g. the credentials for a hosted email account) and probably TLS.

As your local postfix does not receive mail from external sources you can configure it to listen only on localhost (127.0.0.1).
Thanks for the help guys, this is what I was thinking as well.

If I'm not mistaking setting up a relay with an external SMTP is described here: https://www.linode.com/docs/email/postf … tp-debian7">https://www.linode.com/docs/email/postfix/postfix-smtp-debian7 ?

There are a bunch of other articles I found which all pretty much say the same thing, the only thing that confuses me is the following line in '/etc/postfix/sasl_passwd':

[mail.isp.example]:587 username:password

So if I set it up like this I can have one email account for one server?

If I host two wordpress blogs (or any other website), how would I define two different smtp servers?

@hybinet:

2) An email "sending" service through which all automated emails (signup confirmations, password reminders, notifications, contact forms) will be sent. Look up Mailgun, SendGrid, SparkMail, and similar services.

The commercial Google Apps or Office 365 service could be used to accomplish this as well.

Mail originating on the server would travel like this:

Wordpress -> Local Postfix -> Remote SMTP Server (Google Apps or 365) -> Recipient

Your local postfix would be configured to relay mail to the remote smtp server, using authentication (e.g. the credentials for a hosted email account) and probably TLS.

As your local postfix does not receive mail from external sources you can configure it to listen only on localhost (127.0.0.1).

@sleddog:

The commercial Google Apps or Office 365 service could be used to accomplish this as well.

With one caveat: the daily limit will likely be much lower than e.g. SparkPost.

Of course it doesn't matter if OP only sends a few dozen emails a day.

@MissionPC:

If I'm not mistaking setting up a relay with an external SMTP is described here: https://www.linode.com/docs/email/postf … tp-debian7">https://www.linode.com/docs/email/postfix/postfix-smtp-debian7 ?

There are a bunch of other articles I found which all pretty much say the same thing, the only thing that confuses me is the following line in '/etc/postfix/sasl_passwd':

[mail.isp.example]:587 username:password

So if I set it up like this I can have one email account for one server?

If I host two wordpress blogs (or any other website), how would I define two different smtp servers?

If you setup your Postfix as explained in that article, then all email originating on your server will be relayed through mail.isp.example. The configuration in etc/postfix/sasl_passwd provides authentication required for your server to send mail via mail.isp.example.

So you need only one SMTP server.

You can have two blogs or 20, each sending email with a different "From" address, it doesn't matter (of course the "From" address must be legitimate or delivery may well fail). Outgoing mail from all blogs would travel the same route:

Blog -> Local Postfix -> Remote SMTP server (using authentication) -> recipient

There are more complex ways to configure relaying in Postfix. For example, you can define two or more relay servers and then :

  • Use a specific relay server according to the "From" address of an email, or

  • Use a specific relay server according to the "To" address

It all depends on your needs…

@hybinet:

@sleddog:

The commercial Google Apps or Office 365 service could be used to accomplish this as well.

With one caveat: the daily limit will likely be much lower than e.g. SparkPost.

Of course it doesn't matter if OP only sends a few dozen emails a day.

This is true. Though if we're talking about a commercial mail service (paid Google Apps or Microsoft 365) then I'd expect some reasonably high limits. But I don't know…

@sleddog:

If you setup your Postfix as explained in that article, then all email originating on your server will be relayed through mail.isp.example. The configuration in etc/postfix/sasl_passwd provides authentication required for your server to send mail via mail.isp.example.

So you need only one SMTP server.

You can have two blogs or 20, each sending email with a different "From" address, it doesn't matter (of course the "From" address must be legitimate or delivery may well fail). Outgoing mail from all blogs would travel the same route:

Blog -> Local Postfix -> Remote SMTP server (using authentication) -> recipient

Thanks for the help.

So to clarify, if I set it up like this all email will be relayed through mail.isp.example but can be from any "From" address (assuming address is legitimate).

Eg [email protected] and [email protected] (assuming both domains have proper DNS records).

If my SMTP account is "[email protected]", will they user who receives emails see "[email protected]" or "[email protected]"?

Will my sent-box on "john.doe" have all these emails stored? Or everything is passed through without interacting with my "[email protected]" account?

I'm a bit confused when signing up for Google Apps or 365 (in this case 365) how that account relates to this email, is it just used for authentication to their servers/services or the associated mailbox actively sends the email?

Thanks,

@MissionPC:

Thanks for the help.

So to clarify, if I set it up like this all email will be relayed through mail.isp.example but can be from any "From" address (assuming address is legitimate).

Eg [email protected] and [email protected] (assuming both domains have proper DNS records).

Correct.

> If my SMTP account is "[email protected]", will they user who receives emails see "[email protected]" or "[email protected]"?

They will see "[email protected]…" as the "From" address. If they examine the message source they will see from the "Received" lines that the message originated on your webserver and was relayed via an office365 mailserver enroute to them.

> Will my sent-box on "john.doe" have all these emails stored? Or everything is passed through without interacting with my "[email protected]" account?

When you use a server as a mail relay, nothing is stored on the server doing the relaying. It's "passed through" as you say. If you want it stored in the "[email protected]" account, you'd probably need to modify the script sending the message and add [email protected] as a BCC recipient. Or, you could use Postfix's always_bcc configuration to BCC all mail to a given address.

> I'm a bit confused when signing up for Google Apps or 365 (in this case 365) how that account relates to this email, is it just used for authentication to their servers/services or the associated mailbox actively sends the email?

It's used solely for the purpose of authenticating to the office365 mailserver. To relay through the office365 server you must authenticate.

You could, for purposes of clarity, create the email account with a name that reflects it's purpose, e.g. "[email protected]…" If you setup a second webserver you could create a new mail account, "[email protected]…"

If webserver1 is exploited and starts sending spam, you can disable the "[email protected]…" mail account until you get it resolved. Meanwhile webserver2 could continue uninterrupted.

Hope this helps….

@sleddog:

Hope this helps….

Yes, this was off great help!

Thank you.

@hybinet:

@sleddog:

The commercial Google Apps or Office 365 service could be used to accomplish this as well.

With one caveat: the daily limit will likely be much lower than e.g. SparkPost.

Of course it doesn't matter if OP only sends a few dozen emails a day.

For further reference, I just spoke to an Office 365 representative and they said:

"You can send up to 10,000 email per day, 30 per minute and up to 500 recipients." [Business Essential Plan]

More information on the limits can be found here:

https://technet.microsoft.com/en-us/lib … imits.aspx">https://technet.microsoft.com/en-us/library/exchange-online-limits.aspx

Thanks again for all the help.

Most of them are quite similar but there is one we will never use again SendGrid.com !

They can take over two days to respond and their solutions usually boils down to "create a new account".

Mailgun and mailchimp seems better !

I keep SendGrid, Mailchimp, Mailgun, etc. blocked in my server.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct