ryankr1
By:
ryankr1

Configuring Postfix to use my domain

February 18, 2017 177 views
Applications DigitalOcean Ubuntu 16.04

I've got a postfix config that's sending emails just fine, except that the sender address is root@lamp-512mb-lon1-01.localdomain, which isn't using my domain.

The config file looks like the following:

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = lamp-512mb-lon1-01.localdomain
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, skytracker.co, lamp-512mb-lon1-01.localdomain, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_protocols = all
inet_interfaces = loopback-only

and /etc/mailname contains the domain that I would like to use to send emails from.

The command that I'm testing my email sending from is:

echo "This is the body of the email" | mail -s "This is the subject line" xyz@hotmail.co.uk

Any help would be appreciated!

2 Answers

@ryankr1

The line in your configuration that looks like:

myhostname = lamp-512mb-lon1-01.localdomain

... is why you're seeing that :-). That should be your actual hostname (mail.yourdomain.com) or your domain itself (yourdomain.com).

  • Thanks for your response!

    Okay so I've changed that to:

    smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
    myhostname = skytracker.co
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    myorigin = /etc/mailname
    mydestination = $myhostname, skytracker.co, lamp-512mb-lon1-01.localdomain, localhost.localdomain, localhost
    relayhost =
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_protocols = all
    inet_interfaces = loopback-only
    

    I reset postfix with:

    sudo systemctl restart postfix
    

    and sent an email with the same command.

    Unfortunately I'm still seeing the sender address as: root@lamp-512mb-lon1-01.localdomain

    Any other ideas?

Have another answer? Share your knowledge.