0

Scenario:

  • I own the domain example.com.
  • I am signed up with an email provider, and configured my account as a catchall for *@example.com. I use the email dude@example.com.
  • I have a VPS running Ubuntu 18.04, which will host example.com.
  • On the VPS, I have a user called dude.

I want to:

  • configure Postfix as a send-only SMTP server to be able to send email as whatever@example.com. Inspired by this guide.
  • Particularly, I want some system, log, or application messages to be sent to me at dude@example.com and receive them at my external email provider (which I realize could be a little weird, because my VPS user is also dude).

To my novice mind, this seems like it would be a pretty common setup.

Long story short, this is not working quite as expected when I send some test emails to root or postmaster (echo test | mail -s testsubject postmaster). I think I have some ideas about how to fix it, but it has made me think that I might be digging myself into a hole and committing to a bad setup.

So I have some more general questions:

  • Should I completely abandon the user = dude and email = dude@example.com setup? Is that setting me up for crazy problems in the future?
  • Is it a better idea for my server to send as a subdomain? E.g. whatever@mail.example.com.
  • If the above answers are "No", then: can this kind of set up be accomplished with only aliases in /etc/aliases and other config options, or do I need to use virtual alias maps? This is potentially the most detail-oriented of my questions, so I am really only asking in a general sense.

I appreciate any advice folks might be able to give. I've read through all the comments on the guide, looked at lots of the suggested questions here, and have dozens of tabs open across two computers trying to sort this out!

Edit: This is a summary of relevant settings that I've wound up with, which I think are a balance between "works for me" and "I could modify my approach if I needed to, without tearing my hair out". Three files below, with the first being just an excerpt (hence the ellipsis). My understanding is that /etc/aliases never gets used (because example.com, $myhostname, and $mydomain are not in mydestination), but I included it anyway because it was part of my testing, and it seems like good practice to have it.

/etc/postfix/main.cf

...
myorigin = example.com
myhostname = example.com
mydomain = $myhostname
mydestination = localhost.$mydomain, localhost
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
virtual_alias_maps = hash:/etc/postfix/virtual
...

/etc/aliases
postmaster root
root dude

/etc/postfix/virtual
postmaster root
root dude

0

It's possible to send from @example.com and receive the mail with servers listed in the MX records. The crucial part is that mydestination (and virtual_alias_domains / _maps) should not include example.com for local delivery. This way, your dude@localhost won't have address dude@example.com and the mail gets delivered just like with any other domain.

Remember to permit this server in the SPF record for your example.com.

  • Thanks for the insight, Esa! I think the problem I had was that I removed any references to my domain from mydestination, but then I did not have any virtual aliases configured. With everything set up (as shown in my edit above), it seems to be doing exactly what I want. And yes, I got my DNS records all sorted out (SPF, DKIM) - no spam here! – rayhinton Mar 19 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.