I am setting up a linux server that I want to send mail independently of our main mailserver (ie. directly). The problem is, when I send mail to an external address, it bounces with the message domain of sender address does not exist. (it is sending the mail as [email protected])
What is the proper way to change the domain of my email sender?
In main.cf:
This is the default setup. If your
hostname
is domain.local this is probably why you are seeing that as sender domain.You need to fix your domain name in the postfix configuration (domain.local is not a valid domain name).
Check /etc/postfix/main.cf, there are a few ways this can be specified, this may help: http://www.postfix.org/BASIC_CONFIGURATION_README.html#myorigin
This is one of those issues that you will need to involve/bribe/blackmail your DNS admin for assistance on as you will want the name your server claims when trying to send to be correct. Mnay servers will bounce your mail if the sender doesn't correctly resolve both forward and reverse.
For example, let's say your server is mail01.example.com. When your server, with the $myorigin correctly configured to advertise as mail01.example.com, contacts my server, my server will do a DNS lookup of of the IP address you're connecting from and will expect the lookup to match the name your giving me. If it does not correctly resolve, then I will sever the connection because you're probably just sending me spam.
You have to configure your postfix with smarthost because some destination servers verify if the sender address exists.
How to do it here: http://ubuntu.wordpress.com/2005/09/07/setting-a-smarthost-in-postfix/
I have also faced above issue, After updating myorigin's value to the applicable domain name, Issue got resolved. Restart POSTFIX after updating.
Example:
I had same issue ,the cause of this problem was relayhost allowing only mail from mydomain like "acme.com" and not from subdomains like "nagios.acme.com"
I fixed this by updating the "myorigin" parameters value to
First and foremost to correctly set up a mail server so any and all mail you send doesn't get bounced you will need access to your resource records of your domain which are held at whatever DNS provider you have choosen, mine is Google
I will go over the resource records which is all you should need minus my dkim record which I will not be showing.
First is the actual DNS record.
Second is my CAA record that shows who holds my dns certificate so people can not spoof the DNS certificate.
Third is my MX record which tells everyone what mail server I use for my domain. You can have multiple of these with preference based on the integer before the address.
Fourth is my SPF record which tells all who look up my domain what ip addresses are authorized to send mail for my domain.pretty sure you can have multiple ip addresses or possibly even multiple SPF records.
Fifth is my DMARC record which tells mail exchanges what to do with mail not coming from IP addresses in the SPF record, or mail servers not in the MX records. You could possibly get away with creating this and just saying anything goes instead of reject, but still this is the right way.
Sixth would be my DKIM record which is a rsa key that is used to authenticate all mail coming from my domain, and is particularly a pain to get right.
Having done all of that you can then modify the origin configuration and all exchanges will accept your mail with bells and whistles on, as you will pass all three checks like so if you click original message in gmail.
Here is postfix's not so basic, basic configuration
http://www.postfix.org/BASIC_CONFIGURATION_README.html
Here is the documentation from opendkim, otherwise known as domainkeys identified mail, for your dkim server you probably will want eventually.
http://www.opendkim.org/docs.html
And here are some links about MX SPF and DMARC records, otherwise known as mail exchanger, sender policy framework, and
domain-based message authentication reporting and conformance respectively.
https://en.m.wikipedia.org/wiki/DMARC
https://en.m.wikipedia.org/wiki/Sender_Policy_Framework
https://en.m.wikipedia.org/wiki/MX_record
This is all required if you want your emails to be official and accepted by all, and is also good practice to help cut down on the spam/phish/malware in the world.
Also I may have not shown my dkim because it contains a key and is public record just not comfortable with that, but it is also a resource record held at your dns provider like the others that I showed.