Quantcast
Channel: Manfaat Sehat
Viewing all articles
Browse latest Browse all 61

Sendmail: Sending email from different IPs

$
0
0
Sendmail is a highly-configurable, rather complex MTA (message transfer agent) which runs as the default MTA on Red Hat Linux and clones.  I prefer Exim4 for it's simple configuration, but if a client uses Sendmail, sometimes you just need to work with what they're using.

A client asked us to configure their RHEL5 server to send email on different IPs from the same box, so that their marketing emails can come from one IP and, if that IP is blacklisted, they could still email non-marketing info from another IP on that same server.

To do this you first need to ensure that you have multiple IPs on that machine, which is beyond the scope of this article but initial info can be found here.  You'd also need to open your IPTables firewall for the correct SMTP ports, usually 25 and 578, to connect to these IPs from the same machine.

Once you have the various interfaces set up, it's time to work on Sendmail. We first allow the box to relay to itself by adding the IPs to /etc/mail/access file, to look like so:


# by default we allow relaying from localhost...
localhost.localdomain           RELAY
localhost                       RELAY
127.0.0.1                       RELAY
98.205.54.241                   RELAY
98.205.54.242                   RELAY



Next, you can (and should) edit your /etc/mail/sendmail.mc file to have these options:

DAEMON_OPTIONS(`Address=98.205.54.242, Family=inet, Port=smtp, Name=MTA.242, M=b')

DAEMON_OPTIONS(`Address=98.205.54.241, Family=inet, Port=smtp, Name=MTA.241, M=b')




Which, when compiled for Sendmail, makes the /etc/mail/sendmail.cf file have these:

O DaemonPortOptions=Address=98.205.54.242, Port=smtp, Name=MTA.242, M=b

O DaemonPortOptions=Address=98.205.54.241, Port=smtp, Name=MTA.241, M=b



('They' say to never edit the sendmail.cf file directly.)



We can now use the IPs to relay the mail; here is an example with just using Telnet; commands are the first lines and server responses have a quote mark > in front of them:



# telnet 98.205.54.241 25
> Trying 98.205.54.241...
> Connected to vm-98-205-54-241.magichost111.com (98.205.54.241).
> Escape character is '^]'.
> 220 www.someserver.net ESMTP Sendmail 8.13.8/8.12.11; Thu, 23 Aug 2012 12:00:00 -1700

HELO someserver.net
> 250 www.someserver.net Hello vm-98-205-54-241.magichost111.com, pleased to meet you

mail from: localAccount@someserver.net
> 250 2.1.0 localAccount@someserver.net... Sender ok

rcpt to: remoteAccount@gmail.com
> 250 2.1.5 remoteAccount@gmail.com... Recipient ok

data
> 354 Enter mail, end with "." on a line by itself

test from 241 with M=b
.
> 250 2.0.0 q7NH6mwo022159 Message accepted for delivery

quit
> 221 2.0.0 www.someserver.net closing connection
> Connection closed by foreign host.



Much appreciation goes to Grant Taylor and Jim Coates from this thread.

Viewing all articles
Browse latest Browse all 61

Trending Articles