I have a server with sendmail and I need to send email througt PHP. I have an internal SMTP server on the same subnet, so I configured sendmail with FEATURE(
nullclient', mail.server.local')dnl
where mail.server.local is solved with an internal IP in /etc/hosts
There is no way that I can change the from
address and domain. It's always [email protected].
Mar 20 16:18:48 nameoftheserver sm-mta[16402]: v2KFImVi016402: from=<[email protected]>, size=406, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
The output of /etc/mail/sendmail.mc
:
(short domain name) $w = nameoftheserver
(canonical domain name) $j = nameoftheserver.localdomain.local
(subdomain name) $m = localdomain.local
(node name) $k = nameoftheserver
How I can change this values?
So, you are trying to change the envelope sender (as PHP's
mail()
function already handles the "From:" address) with Sendmail. That can be achieved by building a genericstable database to map the input sender address to the address desired.Create a text file
/etc/mail/genericstable
containing the mappings,where the first value is the original username and the second value is the address desired. Or, if this doesn't work with your node server, the original sender address can also be in format
Create another file
/etc/mail/generics-domains
containing the domains, separated by newline. (Notice, that the file MUST include your server's canonical domain name.)Add the corresponding statements to
/etc/mail/sendmail.mc
:Do the normal procedures after re-configuring Sendmail, e.g.