We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


fetchmail from remote host to remote host

mtasking asked
Medium Priority
Last Modified: 2012-05-06
I'd like to use fetchmail to fetch email from a remote smtp server and deliver to another remote smtp server using each servers IP address while DNS change is in progress between both (hence both mailboxes receive email depending on the end-users DNS server).
Watch Question

I've done many e-mail server moves like you are doing, and a problem with what you propose is that fetchmail uses individual IMAP/POP access, so you would need all of your user's usernames and passwords.

Instead, I would recommend the following:

1. Lower the Time To Live (TTL) settings on your DNS A records to 5 minutes
2. Setup and test the new-email server
3. Schedule some downtime
4. Change the IP address that your mail exchanger's DNS A record resolves to
5. Wait five minutes and hut down the SMTP service on the old e-mail server
6. Start copying over all e-mail using server to server copy from the old server to the new one

Fetchmail goes from POP to local email host.  This is okay if the local email server is Linux or you has a windows version of it.   I have used Mercury32 from here http://www.pmail.com/m32_461.htm.  This tool is a mail system in it's own right however it's very light and easy to install ect.  It has a fetchmail type facility but can also send mail smtp.

Coping email over is only an otpion if you are going from two linix machines (assuming the userID's are teh same)
Maciej Ssysadmin

You can't to it directly in fetchmail.
As others wrote - fetchmail fetches emails from remote host to your local box. If you want to have them on other remote host you have to options:
1. launch fetchmail on that remote host directly
2. forward fetched emails from your local host to remote one (with ~/.forward or with ~/.procmailrc).


Thank you for your help and input. The closest answer so far is the suggestion to launch fetchmail on the remote host, however, it's a windows box.
A while back I had fetchmail to pull from a remote host and relay to a remote host but I lost the script. I do remember that I tested on the command line first and then added all users to a .fetchmailrc config file.
See example "Set up Fetchmail" here: http://www.scalix.com/wiki/index.php?title=HowTos/Fetchmail
Example is just not working for me.
Maciej Ssysadmin

-S option means - send received emails through provided smtp host. This can be achieved with procmail (with formail to change your from name to something appropriated) also.
To use -S option, you need to provide smtp server which will accept emails from you (from address provided in --smtpname option).

Please post some detailed informations on what is not working for you. Some error messages can be helpful (they can be available on your terminal, ir you are running fetchmail from commandline, or maybe in /var/log/maillog or /var/log/messages or something like that).

You may want to run fetchmail on your windows box with cygwin - didn't try this, but it may work. Or, maybe just find some windows application which fetches emails :)


If I use this:

fetchmail -v -p pop3 -S x.x.x.x --smtpname johndoe@domain.com -u johndoe@domain.com y.y.y.y

After giving the correct password I see in the verbose output that email is correctly being fetched from y.y.y.y - but instead of delivery to x.x.x.x my local smtp server queues the message locally. My maillog shows this too - local delivery instead of remote forwarding. It may not help that the user actually exists on this local machine, however I'd like to force delivery to x.x.x.x. I changed the transport mechanism in postix to smtp[x.x.x.x] for this user which causes the message to be blocked due to non-local delivery on the remote server.
That fetchmail command is delivering messages to the same server that it's pulling them from. Try this:

fetchmail -v -p pop3 -S x.x.x.x --smtpname johndoe@[z.z.z.z] -u johndoe@domain.com y.y.y.y

Where you replace z.z.z.z with the IP address of the destination SMTP server.
Note that the square brackets in my example are required, and not meant to show an optional parameter.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


That's it, thank you.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.