2003 June 10

Howto configure postfix to use a remote SMTP relay host

This is a public service message, because when I queried google "configure postfix remote smtphost", I couldn't find anything useful to the question I was trying to answer.

So you're running Linux, and your ISP is filtering traffic on port 25, thus blocking you from sending outgoing mail, and so you want to configure your mailserver to relay all your mail out through your ISP's server, like they want you to. If you're running postfix, this turns out to be very easy -- in /etc/postfix/main.cf, just set the variable:

	relayhost = smtp.yourisp.com
then restart postfix (/etc/init.d/postfix restart, as root).

You're welcome.


:( I followed the instructions but my ISP's smtp server bounces my messages telling me that "relaying mail to foo.wherever is not allowed"

Am I doing something wrong?


Posted by: Steve Wollkind on June 28, 2003 04:08 PM

'smtp.yourisp.com' is a placeholder for whatever outgoing smtp server your ISP wants you to use -- they should have told you somewhere. If they have relaying mail blocked on that server, then I dunno. We're out of my depth, sorry.

Posted by: colin roald on June 28, 2003 05:01 PM

Could u pls. give me instructions on how to configure postfix. It will be helpful for my career.

Thanks in Advance.

Posted by: Hemanth on July 8, 2003 09:50 AM

Thanks. Took me a while to figure out that my ISP had blocked this port, I was scratching my head for a while wondering why my mails were all timing out..

This fixed it though. :)

Posted by: Axelay on July 26, 2003 11:54 PM

Thanks for this info. This solved my problem. Turns out, php requires a smtp on the local system, and I had a program in php that only used the php mail() function, so I had to setup postfix to relay to my ISP's mail server when they blocked port 25.

Posted by: David L. on September 23, 2003 09:23 PM


Posted by: GunnieBaby on October 13, 2003 10:40 AM

Actually it wasn't my ISP that was blocking me but rather several mail servers (noteably Netscape/AOL) do not allowed mail in from hosts with IP addresses listed as being dynamic.

So now at least mail can float around on Shaw's mail servers rather then on mine (and in theory get delivered). Thanks for the good info.

Posted by: Archangel on November 11, 2003 11:52 PM


Posted by: Fabian Stietzel on April 16, 2004 06:16 AM

Great - it works for me....

Posted by: RichardG on May 13, 2004 10:19 AM

Thanks dude!

Posted by: Red Five on May 26, 2004 12:48 PM

Kinda defeats the purpose of running a Mail server on your machine. If you can relay thru your ISP's SMTP server, then you can always do this via a GUI app...

Obviously I must be missing something...

Posted by: Musti on May 26, 2004 02:30 PM

Yes, you're missing something.

I do lots of things that generate mail programmatically. Accepting mail from other programs and passing it along is what MTAs are for -- this way, I have only one place (postfix) that has to care that I have restrictions from my ISP, and everything else can just hand off to postfix.

Mailreaders (MUAs) that think they need to know anything about how your ISP handles mail are a silly leftover from toy operating systems.

Posted by: colin roald on May 26, 2004 03:06 PM

is there any way to configure postfix to use the ISP smtp relay only when sending directly fails?

my isp does not block port 25 but i sometimes get blocked due to anti-spam software that does not accept mail but from large ISPs. thanks,


Posted by: aleem on June 5, 2004 11:18 AM

Hi, after I setup relayhost my client can't download the Mail.

I Have one more problem. If I send Mail at postfix it is OK. but receiver do not get the mail.what is wrong with configuration?

Posted by: smathi on July 18, 2004 10:54 AM

I've got a stumper for you:

I need to relay from my local postfix smtp server to my ISP's server - sounds simple right? It's already mentioned up above, right? Well, it is in part...

My ISP's SMTP server is authenticated. How do I set up Postfix to automatically authenticate when relaying to my ISP's SMTP server?


James Addison

Posted by: James Addison on December 18, 2004 01:18 AM
Post a comment
Yes   No   (like the Turing Test, but easier)

TrackBack Links
If you run a blog that supports TrackBack, you can link to this article with this TrackBack key.