Can an email server be set-up on an Azure VM?

24,767

Solution 1

No.

You can't be reasonably sure your outgoing email will be delivered, as many destinations simply blacklist, firewall, or even null route all major cloud providers' IP blocks due to the heavy abuse seen from those ranges - not just from email but via other services as well.

And even if your mail is delivered today, that's no guarantee it will continue to be delivered in future.

You really do need a mail server outside of Azure (or EC2 or whatever) to process your outgoing mail, though it does not necessarily need to be a third party mail server. If you have the expertise, you could do it yourself.

When I put a service on EC2 which had to deliver to a mailing list, I found from testing that almost 3/4 of the list addresses would not accept mail from there. I ended up sending everything to a smarthost located outside EC2. Interestingly, this also improved performance...

Having incoming mail on Azure would be no problem, as the above issues don't apply.

Solution 2

DON'T.

99.999% of the time it makes a lot more sense to use a third-party SMTP / mail handler than to implement your own mail server.

There's even a document on the Azure docs about using Sendgrid.

I highly recommend you follow these guidelines and use Sendgrid (or similar service) as a SMTP relay provider.

The intricacies of setting up a properly configured mailserver are immensely complicated.

Share:
24,767

Related videos on Youtube

Ivan Zlatev
Author by

Ivan Zlatev

Updated on September 18, 2022

Comments

  • Ivan Zlatev
    Ivan Zlatev over 1 year

    I am considering the possibility of setting up a simple SMTP+IMAP email server for internal use on an extra small Azure VM. When I say internal use I don't mean "used by internal users", but for use as part of a larger system and to serve the main purpose of receiving email messages for audit/logging purposes which are then handled based on rules, which trigger actions. Occasionally there might be an automatic response back.

    My question is whether a simple email server can be hosted inside an Azure VM, because what I see on the Internet from a preliminary search is that Azure does not support Reverse DNS (they do assign almost static IPs nowadays though), which will then caused the occasional auto-response outgoing emails to be marked as spam.

    My question is: Is that the case or is there some setup that would allow to workaround this?

    Note: This is just a preliminary research type of question. I am not an administrator.

    EDIT: To those who would jump in and say use SendGrid. I am not going to be sending newsletters, but mainly receiving emails. Also an Azure extra small instance is $9/month where as SendGrid Push API (which won't let let poll as I would like to) starts at $90/month which is ten times the cost.

    EDIT 2: My preference is to implement a poll-based system (poll the server for new emails every X hours) rather than implementing a push+queue based system (most 3rd party servcies provide a Push API that pushes each email to a web url)

    EDIT 3: I would prefer not to use a 3rd party service, because I don't want the content of the email and attachments to go through them.

    EDIT 4: Look, I am not looking for an advice on how to set it up or which 3rd party service to use. What I am asking is "Is it possible to set up an email server which can receive email and send the occasional email out which won't be marked as spam due to limitations of Azure? If there are limitations - what are those and how can they be worked around?"

    • PersianGulf
      PersianGulf over 11 years
      At first, your ip is static? then, if you want to complete leave any spam, please read spamhaus.org rules.
    • voretaq7
      voretaq7 over 11 years
      I'm not saying this to be mean, but if you have to ask "what is involved in setting up a SMTP server?" you're really not ready to take on the challenge of maintaining an internet-connected mail server. It isn't as simple as "start SMTP listener and throw a few records in DNS", and it hasn't been for at least a decade -- you should bring someone in who knows what they're doing, or use an external service provider.
    • Ivan Zlatev
      Ivan Zlatev over 11 years
      @voretaq7 I rewrote my question to be more clear. Essentially, I am not an administrator and I am just doing my preliminary research on whether its possible or not and what are the complications. You could also say that I am more interested in the receiving part than the sending at this point.
    • Anshul Nigam
      Anshul Nigam almost 9 years
      @IvanZlatev, this is exactly what i am searching for a scalable inbound mail server, can you share what you had used finally?
  • Ivan Zlatev
    Ivan Zlatev over 11 years
    My impression with services such as SendGrid is that they provide a facility to send batch emails such as newsletters and similar. My use case is different - I mainly want to receive email, so you answer doesn't really answer my question per se. I have just looked into their Parse API as well, but that starts at $80/month which I simply can't justify for the volume of emails (was thinking of running an extra small Azure VM instance which is $9.36). Additionally in my case it will much much easier to do a poll based system instead of PUSH+queue, which will be required by Push API
  • Tom O'Connor
    Tom O'Connor over 11 years
    It doesn't have to be sendgrid. There are other SaaS and PaaS providers for email that will still mean you don't need to run your own server.
  • Tom O'Connor
    Tom O'Connor over 11 years
    How about Postmark? postmarkapp.com/inbound Looks cheaper.
  • Ivan Zlatev
    Ivan Zlatev over 11 years
    Look, thanks for the Postmark info it's definitely better priced for something like what I have in mind, but essentially my question is "Is it possible to setup a working email server on Azure VM, who's emails won't be marked as spam".
  • Tom O'Connor
    Tom O'Connor over 11 years
    I'm aware of what your question is, but my answer remains unchanged. I'm just stubborn like that.
  • Ivan Zlatev
    Ivan Zlatev over 11 years
    Thanks, that's what I basically wanted to confirm without setting it up - that incoming mails will work.
  • Tonia H
    Tonia H about 8 years
    Hi, a bit old, but nowadays you have reverse DNS azure.microsoft.com/en-us/blog/… so theoretically you can do it.
  • blizz
    blizz about 8 years
    I've set up quite a few SMTP servers on Azure VMs, implemented reverse DNS, and had absolutely no issues with mail delivery. Just my 2 cents.
  • REMESQ
    REMESQ about 8 years
    @blizz New to Azure and am researching setting up SMTP. Could you point to any links/resources on how to get this done? Also, did you get something off the Azure marketplace to run a mail server, or is it a third party program? Thanks!
  • Rodrigo Juarez
    Rodrigo Juarez almost 8 years
    I'm interested in this too
  • franzo
    franzo almost 8 years
    Microsoft is now proactively blacklisting Azure compute IP ranges: blogs.msdn.microsoft.com/mast/2016/04/04/…
  • Dawesi
    Dawesi about 7 years
    none of our Azure mail ips are blacklisted. works just as well as anywhere else. (last 4 years)... since they implemented PTR they may well have changed that policy. Just use mxtoolbox to monitor anyway, then remove yourself if listed. Most blacklists are automated, so MS can't add the ranges anyway.
  • Dawesi
    Dawesi about 7 years
    99.999% really? "The intricacies of setting up a properly configured mail server are immensely complicated." Well it's 3 years later and setting up and delivering emails is still a science, but one that can be learnt reasonably quickly from blogs and articles form the experts. Our deliverable rate is close to perfect off Azure. Learn the craft, setup your own mail server and tweak the setup (mail/dns/etc) until you get great results. MS even helped us #irony Go for it, Tom has one opinion. I disagree (from experience)