[SOLVED] How to Configure SMTP Server which can relay mail based on IP address
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
#vi /etc/mail/sendmail.mc
(add these lines or check if they exist)
define(`SMART_HOST', `smtp.your.provider')dnl <--------------provide the details of smtp server in my case I use smtp.gmail.com
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl <--------------port for relay
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl <--------------port for smtp
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl---------------------------------->uncomment this line as done here
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl------------->uncomment this line as done here
FEATURE(`authinfo', `hash /etc/mail/auth/client-info.db')dnl------------->add this line
dnl # DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl---------------->uncomment and remove loopback
FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl --------------> make sure this line is uncommented
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl------------------------>remove loopback address
I need the server which is able to receive an email from specific IP address and then relay it to outside. no other IP's which are not in allowed list can realy email from my SMTP server.
I need the server which is able to receive an email from specific IP address and then relay it to outside. no other IP's which are not in allowed list can realy email from my SMTP server.
Code:
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
instead of 127.0.0.1 give your IP
Do we required first configuration with secondone which you have suggested here.
and this configuration will relay mail comes from specific IP address (Specifica SMTP server) and relay it to outside?
Lets Say it will receive mails from 192.168.0.254 server and realy it to ourside if i will do "DAEMON_OPTIONS(`Port=smtp,Addr=192.168.0.254, Name=MTA')dnl"?
Do we required first configuration with secondone which you have suggested here.
and this configuration will relay mail comes from specific IP address (Specifica SMTP server) and relay it to outside?
Lets Say it will receive mails from 192.168.0.254 server and realy it to ourside if i will do "DAEMON_OPTIONS(`Port=smtp,Addr=192.168.0.254, Name=MTA')dnl"?
Sorry for the late reply
yes, all the mails will pass from this IP which will act as a RELAY but don't forget to mention the IP in access file and map it to access.db
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.