LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-06-2019, 03:05 AM   #1
karthik-techie
LQ Newbie
 
Registered: Nov 2019
Posts: 4

Rep: Reputation: Disabled
Postfix server - Setup multiple relay hosts based on request IPaddress


I am using postfix SMTP server. As per my requirement, Now I want to setup 2 SASL accounts to send mails through 2 relay hosts. Those are

1) user1@example.com - relayhost - sendgrid

2) user2@example.com - relayhost - local smtp server

Now, I am integrating

user1 account in website-1 user2 account in website-2 when the request came from website-1, mails should go from sendgrid and request came from website2 mails should go from local SMTP server(installed in server). I have done this setup with "transport" configuration(/etc/postfix/transport file). In transport configuration, we are giving domain names. Now, I want give IP address instead of domain names.

How we can route mapping by IP address?

It means, when request came from IP address 'X', mails should go from sendgrid and request came from IP address 'Y' mails should go from local SMTP server(installed in server). Please provide your suggestions to achieve this requirement. Thanks in advance.
 
Old 11-06-2019, 07:48 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,315

Rep: Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017
Quote:
Originally Posted by karthik-techie View Post
I am using postfix SMTP server. As per my requirement, Now I want to setup 2 SASL accounts to send mails through 2 relay hosts. Those are

1) user1@example.com - relayhost - sendgrid
2) user2@example.com - relayhost - local smtp server

Now, I am integrating

user1 account in website-1 user2 account in website-2 when the request came from website-1, mails should go from sendgrid and request came from website2 mails should go from local SMTP server(installed in server). I have done this setup with "transport" configuration(/etc/postfix/transport file). In transport configuration, we are giving domain names. Now, I want give IP address instead of domain names.

How we can route mapping by IP address? It means, when request came from IP address 'X', mails should go from sendgrid and request came from IP address 'Y' mails should go from local SMTP server(installed in server). Please provide your suggestions to achieve this requirement. Thanks in advance.
Did you try putting the IP addresses in the transport file, instead of the names???
 
1 members found this post helpful.
Old 11-06-2019, 07:52 AM   #3
karthik-techie
LQ Newbie
 
Registered: Nov 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
Yes, I tried with IP address in transport file. it's not working. Thanks for your reponse.

Last edited by karthik-techie; 11-06-2019 at 07:53 AM.
 
Old 11-06-2019, 08:17 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,315

Rep: Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017
Quote:
Originally Posted by karthik-techie View Post
Yes, I tried with IP address in transport file. it's not working. Thanks for your reponse.
Did you rebuild the transport DB after you modified it with the "postmap /etc/postfix/transport" command? Did you restart Postfix? What was the entry you tried in the transport file?? Without knowing what you've done past saying "not working", we can't say much and we can't guess. The format should be
Code:
example.com smtp:[1.1.1.1]:2222
...for the IP and port.
 
Old 11-06-2019, 08:54 AM   #5
karthik-techie
LQ Newbie
 
Registered: Nov 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
Sorry for that. My transport file is:
Code:
mywebsite.com smtp:[smtp.sendgrid.net]:587
.mywebsite.com smtp:[smtp.sendgrid.net]:587
This is working fine and mails are going through "sendgrid".
But I need this configuration with IP address. So, I changed it like:

Code:
58.184.000.187 smtp:[smtp.sendgrid.net]:587
58.184.000.187/32 smtp:[smtp.sendgrid.net]:587
then, I run the command "postmap /etc/postfix/transport" then restarted postfix and dovecot.

Now, mails are not going through "sendgrid", those mails are going local SMTP only. Please give your suggestions.

The main reason for my requirement is:
My Website-1 is a website builder. It means we are creating new websites to the customers. So, every customer has his own website with new domain names.
So, I can't set condition(in transport file) on domain names for relaying. If I set condition on IP address, My websites-1's all customer domain mails will go through sendgrid and website-2 mails will go through local SMTP server.

Last edited by karthik-techie; 11-06-2019 at 08:55 AM.
 
Old 11-06-2019, 08:58 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,315

Rep: Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017Reputation: 6017
Quote:
Originally Posted by karthik-techie View Post
Sorry for that. My transport file is:
Code:
mywebsite.com smtp:[smtp.sendgrid.net]:587
.mywebsite.com smtp:[smtp.sendgrid.net]:587
This is working fine and mails are going through "sendgrid".
But I need this configuration with IP address. So, I changed it like:

Code:
58.184.000.187 smtp:[smtp.sendgrid.net]:587
58.184.000.187/32 smtp:[smtp.sendgrid.net]:587
then, I run the command "postmap /etc/postfix/transport" then restarted postfix and dovecot.

Now, mails are not going through "sendgrid", those mails are going local SMTP only. Please give your suggestions.
I suggest you re-read my last post, and look carefully at the example you were given, because that is *NOT* what you have in your file.
Quote:
The main reason for my requirement is:
My Website-1 is a website builder. It means we are creating new websites to the customers. So, every customer has his own website with new domain names.
So, I can't set condition(in transport file) on domain names for relaying. If I set condition on IP address, My websites-1's all customer domain mails will go through sendgrid and website-2 mails will go through local SMTP server.
Ok.
 
Old 11-06-2019, 09:23 AM   #7
karthik-techie
LQ Newbie
 
Registered: Nov 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
I red your post again. Sorry. I got my mistake. I gave my email domain in transport file.I didn't give my domain name.

My domain: example.com and my email id: karthik@xyz.com.

When I gave my email domain in transport file, the code is
Code:
xyz.com smtp:[smtp.sendgrid.net]:587
.xyz.com smtp:[smtp.sendgrid.net]:587
So, mails are going through "sendgrid".

Now I tried it with my website domain. my transport file is:

Code:
example.com smtp:[smtp.sendgrid.net]:587
.example.com smtp:[smtp.sendgrid.net]:587
Mails are not sending through "sendgrid.
Please give suggestions to achieve my requirement. Thanks for interacting with me.
 
  


Reply

Tags
postfix postfixadmin, saslauthd, smtp


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
554 5.7.1 Relay access denied Postfix Open Relay kryspek Linux - Software 5 04-26-2017 09:35 AM
How to set up multiple SSL sites for multiple IP based and name based Virtual Hosts. Rohit_4739 Linux - Server 11 02-28-2011 09:28 AM
Postfix Relay Getting Spammed Bad -- But no open relay... ihod2008 Linux - Server 1 07-26-2008 09:24 PM
after chnaging the ipaddress of nagios server new hosts adding error sridhar11 Linux - Software 0 10-26-2005 02:07 PM
Postfix as a mail relay (getting relay access denied) hypexr Linux - Software 3 09-13-2005 08:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration