I was struggling for a while trying to send my mails using smtp.gmail.com. I have a few debian boxes where the mail agent is exim4. It turned out to be quite simple:
run 'dpkg-reconfigure exim4-config'
- dpkg-reconfigure exim4-config
- select the computer type 'sending with smarthost'
- select the smarthost to be 'smtp.gmail.com::587'
- Select the other options in a meaningful way
- Now edit the file /etc/exim4/passwd.client and add the lines:
You do not have to specify '@gmail.com' part for the name. Do not leave spaces around the name and password.
- edit the file /etc/exim4/email-addresses (debian etch) or /etc/email-addresse (debian lenny) and add the line:
This writes a meaningful sender address instead of user@localhost.
- /etc/init.d/exim4 restart
The relevent SMTP server name may change. Send a test letter and consult /var/log/exim4/mainlog
That's it! Enjoy!
Note: the mails will be sent with your gmail address as sender. However, reply-to address is what you write to the file email-addresses.