Portal Home > Knowledgebase > Articles Database > Mail sending from wrong hostname


Mail sending from wrong hostname




Posted by sh4ka, 05-24-2010, 05:34 PM
Hello, I have one server, plain CentOS 5.4, i686, Sendmail-8.13.8-8. This server has "mysql.server.com" as hostname, it has been in this way since about 2 years. Since then, all mails sent from the command prompt (example: echo "test" | mail -s "test subject" my@email.com) arrived as this: root@mysql.server.com, which is ok because mysql.server.com is the hostname of the system. The problem is that since today morning, emails are arriving as another hostname : root@server.com server.com domain is hosted at another DC, and it's not set as hostname, so.. i don't know how it could change like that.. Even using a PHP script and altering the headers of the email, it sent all as mailbox@server.com, which is wrong: In this case is different than sending from echo command provided on top, but, it arrives in this way: From: newsletter@server.com While it should arrive as: From: newsletter@onedomain.com Any ideas? I already restarted sendmail, verified "server.com" is not set at any system file as hostname, rebooted the system and verified logs, can't find anything wrong. Thanks a lot!

Posted by fbroce, 05-24-2010, 06:00 PM
I don't know why it would change however, you might check your /etc/hosts file and make sure server.com is not listed as a hostname (I know you said you checked system files). Sendmail gets the hostname from the hosts file unless you have it configured elsewhere. Also you could telnet localhost 25 and type ehlo localhost. You should see the sendmail hostname in the message.

Posted by sh4ka, 05-24-2010, 06:11 PM
Thanks for the suggestions but had no luck, this are the results: At /etc/hosts i only got my real hostname listed and localhost: Telnet shows the correct hostname too: Last edited by Mike V; 05-25-2010 at 01:00 PM.

Posted by sh4ka, 05-24-2010, 06:17 PM
This are the logs while sending: And mail arrives as: This is really weird

Posted by fbroce, 05-24-2010, 06:53 PM
Do you have any aliases? Does sound weird. Look at the mail headers..Maybe they will give you a clue. Also look at /var/log/maillog.

Posted by nebula99, 05-24-2010, 07:14 PM
You can also set the return-path in PHP to be whatever email and domain your wish. From the PHP man page, there is this comment: Note that you may also have to set your shell user as a "trusted user" in your mailer configuration (e.g. /etc/exim.conf) for this option to work. - El Capitan

Posted by sh4ka, 05-25-2010, 08:24 AM
It seems this is a hostname problem, this is what I got so far: [It seems sendmail is taking the $m variable, don't know why yet. Any ideas how to change that? Thanks.

Posted by fbroce, 05-25-2010, 08:56 AM
Try typing env from a shell prompt and see if you have any shell variables set that point to server.com. It must be a shell script that has server.com as the default server.

Posted by sh4ka, 05-25-2010, 09:54 AM
From php is sending ok now, it was a dns record bad pointed. But from shell is still a problem, will investigate. Thanks dude.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Cloud App (Views: 520)