9

Have an SMTP server setup running in postfix, only for sending mails . Now the requirement is i want to relay mails for particular domain to end user through other SMTP , without disturbing default setup (i.e, without relaying)

Existing Setup

   Application -->  My SMTP  ---> End user

Required for particular domain to send mails

 Application ( siva@abc.com ) --> My SMTP  --> SMTP of XYZ.com
Cakemox
  • 24,141
  • 6
  • 41
  • 67
Sivaguru Nathan
  • 101
  • 1
  • 2
  • 3

1 Answers1

20

If you want to send to a server other than what say the MX records in DNS for a domain, you can add a line in /etc/postfix/transport:

abc.com        smtp:mail.xyz.com

Then run postmap /etc/postfix/transport.

If it isn't already, add transport_maps = hash:/etc/postfix/transport to /etc/postfix/main.cf and run postfix reload.

Cakemox
  • 24,141
  • 6
  • 41
  • 67
  • Thankx Cakemox, but how can i confirm whether the mails from abc.com using my SMTP as origin and mail.xyz.com as RELAY .. any logs to identify – Sivaguru Nathan Apr 09 '11 at 17:00
  • Postfix uses the mail facility of syslog which usually goes to /var/log/mail.log – Cakemox Apr 09 '11 at 17:37
  • Whether the mail.xyz.com want to allow accept abc.com as relay in their server. Pls clarify – Sivaguru Nathan Apr 10 '11 at 04:53
  • Normally you just rely on DNS to determine the SMTP server for abc.com. Is there a reason why you want to send it to mail.xyz.com if you're not sure they will accept email for abc.com? Are you hoping to use mail.xyz.com as an open relay? – Cakemox Apr 10 '11 at 05:19
  • Not as open relay, just another level of verification, the thing is we have an SMTP server to send mails from application, but one our client requirement is instead of generating mail to Internet directly , it should also go to their SMTP server and then to Internet or end user . – Sivaguru Nathan Apr 10 '11 at 09:24
  • 1
    +1 for this answer. Additionally, you can specify via IP address by using smtp:[ip.add.re.ss]. The [] suppresses MX lookups and forces the system to try to send to whatever destination you've specified. http://www.postfix.org/transport.5.html – Greeblesnort Apr 14 '11 at 19:50
  • Hi Greeblesnort, Still can't send mail via corresponding SMTP, using the above mentioned configuration – Sivaguru Nathan Apr 17 '11 at 10:02
  • 3
    Is there any way to specify a username and password for the relays for those cases when a relay requires SMTP AUTH? – QuantumMechanic Dec 12 '17 at 21:38