Setting up an email proxy server?

8,764

Solution 1

I can't (yet) comment so I will try to answer the way I understood the question.

It seems you want to place a relay SMTP server in between your 4 app servers and your "final" SMTP server.

If I understood it correctly and if you are using Linux, I would suggest you use postfix configured as a relay for your 4 app servers.

Once installed, postfix offers lots and lots of configuration options in its main config file (usually /etc/postfix/main.cf), but you are very interested in the ones below:

relayhost = <smtp_out_server>
smtpd_client_restrictions = <IPs from your appservers> # only they can connect!

Review the rest of main.cf to ensure sane configs (when I did a similar work, all defaults for small traffic were OK) and you should be good to go.

If your relayhost needs a user/password authentication, then you will need to configure SASL authentication. In this case, follow this additional steps:

1) Ensure sasl2 and sasl2-plug-plain packages are installed (generally yes)

2) setup an /etc/postfix/sasl_passwd file with the following info: <smtp_server> <smtp_user>:<password> (note the blank space between and the rest of the line)

3) chmod 600 sasl_passwd to make it as safe as possible;

4) run postmap hash:/etc/postfix/sasl_passwd to generate the password map;

5) Add the following to main.cf

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =

6) reload postfix with service postfix reload

... and you should be good to go (again).

Hope this helps,

UPDATE

If I understood your update correctly, what you want to do is answered by this other SF question: Remove/hide client sender ip from postfix?

HTH.

Solution 2

You're already using a relay server.

Your existing configuration is using a single SMTP server to relay email to the recipients email servers on behalf of the application servers (as opposed to the application servers sending the email to the recipients email servers directly). Why are you wanting to add an additional relay server to the mix?

With your proposed solution your new relay server would accept email from the application servers and then relay them to the existing relay server which would then relay them to the destination recipients email servers.

Solution 3

This is called an email relay, and any mail server can do it easily.

A setup with Postfix, the usual default mail server, is as simple as installing it from packages and then setting mynetworks in main.cf to the IP addresses of the machines allowed to send mail through that host.

Share:
8,764

Related videos on Youtube

Raymond Holguin
Author by

Raymond Holguin

Updated on September 18, 2022

Comments

  • Raymond Holguin
    Raymond Holguin over 1 year

    So i have 4 application servers and each one directly connects to an SMTP server to send out the emails. What I want is to have something in the middle that my servers connect through instead, and that middle-ware (?) will be what pushes my emails through to the SMTP server. So this SMTP server will only see emails coming from one source instead of 4.

    I am unfamiliar with how this sort of thing works, but It sounds like I need to create my own SMTP server which would accept the incoming requests and send them off to the main SMTP?

    I just need something very lightweight and basic as its just going to be these servers accessing it and it will be only have the function of relaying these emails. Any help to get me going in the right direction would be appreciated.

    UPDATE

    Thanks for the corrections in that what I am looking for is an email relay. There is a reason though I used the work "proxy" and I mistakenly did not explain that clearly.

    What I want is the new relay to assume the role of the sender of the email. With a web proxy the user IP is hidden and the traffic appears as though its from the proxy IP. That's what I want for this email relay. My relay IP should appear to be the sender, not the application servers as those should be hidden.

    So no matter which application server sends the email, the sender IP should always appear to be the relay I setup. Is that possible?

  • jgomo3
    jgomo3 almost 7 years
    One possible Example. The SMTP is smtp.gmail.com. Your apps are now behind a FW and can't reach the gmail server. In the DMZ you install a relay server that will foreward to gmail. Why? because you want the message to be "sent" from gmail, not from your net. @joeqwerty Does this example would justify the indirection?