2a19ba9da5114ba8b662e066b2c7c41a0343702c
By:
nikbs

Mail server solution, to create a custom ticketing system

November 14, 2015 2.8k views
Email Getting Started Security MySQL LAMP Stack PHP DNS Networking Ubuntu

I need an incoming and outgoing mail solution that is stable and reliable and doesn't take too much resources.

For the outgoing mail, I want to be able to send from multiple domains (through php cron) with DKIM signature and all other email standards to make sure my recipients will receive the messages and my domain will stay off the black lists.

While for the incoming messages, I would like to have a lot of aliases. And if possible tinker with the code. Ideally id like to be able to check new messages with cron and add them to a DB.
What I'd also like is to be able to send canned replied upon receiving a message. So something like a ticketing system.

I've seen a bunch of different tutorials on here for Ubuntu 14.04, but I am not sure which mail server will allow me to do this.

Can i get any recommendations that will enable me to do at least some of the things I mentioned above?

Thanks

2 Answers

If you asked this one-two months ago, I'll recommended you to set up old-fashion Postfix or one of its alternative or in case of lazy mood you always can use Google/Yandex-based mail-hosting.

But I found the great solution: Mailgun software-as-a-service. I sure, there is a lots alternatives (or clones), but I didnt tried to search them just because of Mailgun fits all requirements of my dreams.

First of all - Mailgun have full-featured RESTful (JSON) API with useful things like webhooks, in & out rules, filters, automatic DKIM handling, routes for mail and lots lots more (see docs). No more hours of tuning some modules, proxies, "why its not work?!" and other that I had everytime trying to get postfix work proper. I am not network administrator and its possible reason of all my fails with private SMTP/IMAP-server setup. No matter.

Next. I still feel that its my email, not their. I have domain owned by me, everything in admin-panel is freely importable\exportable

I really like it. I cant find positive answer to question: do I really need huge mail-server software to deliver notifications from my projects?

About aliases. I am may be wrong but this looks like classic "username@domain + aliases" identity set is a thing not about Mailgun. They have really flexible, powerful and easy to understand builtin rules/routes/forwardings/parsers etc etc etc. You can setup simple alias implementation there

Only one bad thing I found is 10 000 emails can be sent for free monthly. For me its enough for lifetime. Thats only one limitation.

P.S.: read my post and want to ask myself "how much you got for this low-quality ad?" But really, its real feedback, I was shocked of this product.

  • So I was playing around with Mailgun. Testing it on various platforms, when I noticed none of the messages sent to iCloud are being delivered...
    I'm not so certain what is the problem. I mean it works with Gmail, Outlook, Yahoo but not with apple.

    I was using their API, literally copy and paste to a PHP file just to test it out. So I don't think it has to do with me.

    Have u gotten anything similar?

    I'm digging it though. I think I will be implementing this for all my apps...so far I went with a custom SMTP app run by CRON.
    Still plan on using CRON to send the emails from my DB, just through their service. Thank you for recommending them.

    Now I just hope this issue with iCloud gets solved.

@nikbs

Having worked with Linux for over 10 years, I'll be the first to tell you that setting up, running and maintaining a working mail server can be a royal pain! There's a lot to keep up with (standards, protocols, ports, spam etc) and backing up your configuration is an absolute must; no exceptions!

I say this not to deter you, though unless you've got plenty of free time, using a service, such as the one mentioned (MailGun) or a similar alternative, such as Mandrill, SendGrid etc, is a much better and far more reliable solution. This is even more so true if you're looking for a lightweight solution.

While using such services will require that you're able to code, all three that I mentioned have SDK's for PHP, Python and various other programming languages, so the initial bar to entry is lowered.

That being said, many of the SDK's rely on third-party libraries (specifically the PHP SDK's), so if you're the type who craves complete control over your code (like me!), the best solution is to create your own SDK and wrap it around the API.

In the case of MailGun, which I happen to be working with right now, mail is sent and received through their service and you would setup your MX records to point to theirs. You would then create aliases on their servers through their control panel and define the route that the service pushes your e-mail to.

For example, if you setup user@yourdomain.ext, you can choose to store the incoming messages for up to two days (free accounts, I believe paid accounts allow for longer storage periods). During this time, you'd simply call the API to fetch the e-mail and in turn, parse the JSON and store it to your DB (or do whatever you'd like with it). You can also have the service "POST" the request to a URI, thus you could setup automatic parsing for each request as it is received, thus negating the need for a CRON Job.

You'd simply enter in the URI and when a request is received, MailGun will make a POST request and from there, your script will handle the request.

Mail, of course, can be sent from your script through MailGun as well.

  • I'm really liking Mailgun. Been playing around with it for a bit...

    And will be only sending the mail from a script, I need CRON to fetch stuff from a DB and send it to their API. So far very impressed, except the issue of emails not being delivered to iCloud, guessing it's a bug of theirs as it works for all others like Gmail, outlook & yahoo.

    Their other features like lists and tracking and such don't particularly interest me as I'm handling those from my side.

    • @nikbs

      Have you setup an SPF entry in your DNS zone? Many provides, Google, Yahoo, AOL and others, all check for such an entry. In many cases, if this DNS entry does not exist, your e-mail will bounce or automatically be "black-holed" as they have no way of otherwise validating where the e-mail originated (as anyone can spoof the sender).

      • Yes, I have. To get the domain activated for use with MG you have to...

        • @nikbs

          That's odd - I'd definitely get in touch with their support team. I've dealt with my fair share of issues with Google and Yahoo in the past, though I've never had issues with delivery to iCloud. Normally they'll accept anything (living proof is one of my iCloud accounts now, sadly :-)).

          • They seem to have fixed the problem, this is their response: "We've adjusted the sending IP for the domain. Let us know if you still experience any delivery issues."

            Thanks again for your input @jtittle.

Have another answer? Share your knowledge.