Qmail sending messages as anonymous@ or root@
Recently, I’ve discovered that all email being sent via script through my mail server, a Qmail server, was arriving with anonymous@servername and root@servername as the from address rather than the specified From in the message headers. After several hours of Internet research, I happened upon a message that solved another issue, but included a bit of information helpful to my situation. Due to the huge SPAM problem the world is having, mail servers are now displaying the Return-Path for the message, which basically is the actual system user responsible for sending the email. This helps mail servers determine which servers are responsible for SPAM via open relay and the like. When you send mail via email client, the Return-Path is already set to your email address, so this problem won’t affect you there.
To get your From address workign again for your formmail scripts, you need to add the following code to your script before sending the mail. (Note: the @ will be applied by the server, so the alias is the only thing necessary for the MAILUSER)
Perl:
$ENV{'MAILUSER'} = 'myusername';
$ENV{'MAILHOST'} = 'mydomain.com';
PHP:
putenv("MAILUSER=myusername");
putenv("MAILHOST=mydomain.com");
Another easy to fix this is to add the Return-Path to the header portion of your mail function:
Return-Path: Alias <alias@yourdomain.com>
Leave a Reply of Your Own