PostFix send emails as domain.localdomain instead of domain.org

June 7, 2017 725 views
Email Ubuntu 16.04

So, I,ve setup up postfix in my server following this article https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-16-04. Whe i make the indicated test of the article mails are reviced as root@innovaclub.localdomain instead of the desire @innovaclub.org. I uncommented the myorigin = /etc/mailname line and edited the mailname file adding innovaclub.org in the firstline but still not working. Any help will be much appreciatte.

4 Answers

Hi @arieltoledo

Try running this command to validate the specific myorigin:

postconf | grep myorigin

You can show all the Postfix configuration by running just postconf. Remember to restart Postfix after changing the configuration - otherwise it isn't active.

But it might be Apache/PHP that is actually doing this, which can be fixed by setting the sendmail_path correctly by adding the following line to the Apache vhost config:

php_value sendmail_path "/usr/sbin/sendmail -t -f hello@innovaclub.org -i "

Or it can again be overruled by Postfix smtp_generic_maps:
https://stackoverflow.com/questions/14370224/change-outgoing-mail-address-from-rootservername-rackspace-sendgrid-postfix

@hansen thanks for reply.

I follow this steps.
1.-

postconf | grep myorigin
append_at_myorigin = yes
myorigin = /etc/mailname

2.-

cat mailname 
innovaclub.org

Seems Postfix config looks ok.

3.-
Added this to my 000-default as my server its going to manage only 1 website.

  <Directory /var/www/html/>
            php_value sendmail_path "/usr/sbin/sendmail -t -f info@innovaclub.org -i "
            Options FollowSymLinks
            AllowOverride All
            Require all granted
   </Directory>

  1. Try added smtp_generic_maps = hash:/etc/postfix/generic but after that postfix wont send emails.

So far none of this work. still getting root@innovaclub.localdomain

  • @arieltoledo
    Have a look in /etc/hostname too. I'm not sure why it's behaving like that, but it's a configuration issue somewhere - since I have several Postfix installations that run as send-only and I only set a few parameters together with myorigin.

@hansen thanks ! that did the trick hostname was set to "innovaclub" instead to innovaclub.org. Now its working.

First step done. Now I have to config php to send mails trought smtp postfix to avoid going directly to gmail spam folder.

  • If you're running WordPress or similar, you could use SparkPost:
    https://www.sparkpost.com/
    https://wordpress.org/plugins/sparkpost/

    Otherwise, you simply need to set the configuration to use localhost as SMTP server, which I believe it already is by default, so when you use the built-in PHP function mail it will go thru Postfix.

    • Im using wordpress but I developed my own theme with a custom form so Im using the built-in PHP function mail. I have reconfigure the spf records, gotta wait until they spread to see if i can avoid the spam filter.

    • This message its in the header spf=fail (google.com: domain of root@innovaclub.org does not designate 45.55.233.253 as permitted sender) so I added “v=spf1 ip4:45.55.233.253 ~all” to my records to see if it pass

You need to delete the other SPF records - you should only have 1, and I can see 3 currently.
And the record should be (without any quotes):

v=spf1 a include:_spf.google.com ~all
Have another answer? Share your knowledge.