Jump to Navigation

169 - Send e-mail from a localhost as not spam

Set up masquerading to modify the domain name of all traffic originating from and passing trough your mail server.
This is to set up a SMTP server in outside of local network & masquerading setting for sendmail.

1. Edit /etc/mail/sendmail.mc.

# vi /etc/mail/sendmail.mc


define(`SMART_HOST',`smtp0.iij-america.net') dnl
MASQUERADE_AS(`ntcltdusa.com') dnl
MASQUERADE_DOMAIN(ntcltdusa.com) dnl
MASQUERADE_DOMAIN(localhost.localdomain) dnl
MASQUERADE_DOMAIN(localhost) dnl

FEATURE(masquerade_envelope) dnl
FEATURE(masquerade_entire_domain) dnl

(To aqvoid an extra line break in terms of "m4", to add "dnl" in the end of the line.)

2. Generate sendmail.cf file from the mc file.

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

* You need the following packages.


3. Change Mail Format of headers in sendmail.cf (optional)

* Edit /etc/mail/sendmail.cf

Before :

HReceived: $?sfrom $s $.$?_($?s$|from $.$_)
$.$?{auth_type}(authenticated$?{auth_ssf} (${auth_ssf} bits)$.)
$.by $j ($v/$Z) $?r with $r$. id $i$?{tls_version}

Received: from VAIO-XXXX ([192.168.0.XXX]) by mail.mydomain.net (8.11.1/8.11.2)

After :

HReceived: $?sfrom SMTP
$.$?{auth_type}(authenticated$?{auth_ssf} (${auth_ssf} bits)$.)
$.by $j (SMTP server) $?r with $r$. id $i$?{tls_version}

Received: from SMTP by mail.mydomain.com (SMTP server)

4. Restart sendmail process.

# service sendmail restart


# /etc/init.d/sendmail restart

5. Check your relay SMTP server.

# /usr/sbin/sendmail -bv usr01@mydomain.com
usr01@mydomain.com... deliverable: mailer relay, host smtp.mydomain.net, user usr01@mydomain.com



Main menu 2

Story | by Dr. Radut