how to choose an appropriate Droplet hostname for LAMP and Sendmail/Postfix with multiple domains?

June 19, 2019 631 views
LAMP Stack Networking Ubuntu 18.04

I initially set my droplet name to ‘my-first-droplet’, not knowing really what the implications would be. I am successfully hosting 4 domains on the same droplet using LAMP/https/virtualhost configurations. However I am failing to implement Sendmail/Postfix for sending mail via PHP. I suspect that my Droplet’s hostname is causing this, as configuring mail asks for a FQDN, which my droplet’s is not really a valid FQDN.

How can I choose an appropriate hostname and setup sendmail/postfix for my droplet when I have 4 domains, each not taking priority over another so picking 1 for the hostname seems inappropriate. Is hosting several domains in 1 droplet even recommended?

3 comments
  • Hi there,

    Hosting multiple sites within a droplet is fine!

    I believe that your droplet’s hostname should not affect sendmail/postfix as long as you give it a FQDN that resolves to the IP address of the droplet.

    In terms of choosing which domain to use, that is really up to you at the end of the day.
    If only one of the domains is your personal one, I’d use that so it’s “linked” to you.

    Hope that helps!
    - Matt.

  • Great- my sendmail is functioning after updating my hostname to a FQDN that points to my droplet. One issue now is that my hostname (personal domain as suggested) is now exposed in the FROM address when sending mail from another domain:

    no-reply@another-of-my-domains.com via my-personal-domain.com 
    

    I am sending like this in PHP:

    mail("myemail@gmail.com", 'test from DO', 'test mail from DO', 'from:no-reply@another-of-my-domains.com');
    

    How could I eliminate this ‘via my-personal-domain.com’ in FROM?

  • @eatmybinx I’ll be honest, it has been a long time since I last used sendmail 😂
    From what I recall, you’ll need to add all the domains you wish to act as to your sendmail config file under MASQUARADE_AS, I’m thinking that might then convince sendmail your from header is valid.

1 Answer

This question was answered by @MattIPv4:

Hi there,

Hosting multiple sites within a droplet is fine!

I believe that your droplet’s hostname should not affect sendmail/postfix as long as you give it a FQDN that resolves to the IP address of the droplet.

In terms of choosing which domain to use, that is really up to you at the end of the day.
If only one of the domains is your personal one, I’d use that so it’s “linked” to you.

Hope that helps!
- Matt.

View the original comment

Have another answer? Share your knowledge.