Daily Archives: December 21, 2013

Debian Squeeze: Configuring Sendmail to relay through your Provider’s SMTP

If you have a home server and you need a functionality of sending an email from that server like for example: you forgot your password of a php website and you want to request an access (a new password) using an external email address. This task is almost impossible if you have a server without dedicated IP address, is also useful to have the right design for your website using services from sites as https://the-indexer.com/web-design-companies/. In this example I have a Faxserver on my home server and I want to set a new password. But if I click on “Forgot your Password?”, put my email address in and click send. Checked my email and nothing happened.

avantfaxThe reason for that is the remote mailserver will reject any email from my home server.

After some reading (from this link) and trial I managed to make it working to relay sendmail through my provider’s SMTP server. Here’s how I did it:

1. From Synaptic, install “sendmail-bin” and “sendmail” (if they are not already installed):

sendmail_012. Using your favorite editor put the following line into “/etc/mail/auth/client-info”:

AuthInfo:<your-smtp-server> "U:root" "I:<your-email-address>@<your-provider>" "P:<your-password>"

3. Create database hash from that file:

cd /etc/mail/auth
sudo makemap -r hash client-info.db < client-info

4. Change file permission of both files to 600:

sudo chmod 600 *

5. Change “/etc/mail/auth” directory permission to 700:

cd ..
sudo chmod 700 auth

6. Add following text to the end of file “/etc/mail/sendmail.mc”:

define(`SMART_HOST',`<your-smtp-server>')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl
define(`CERT_DIR', `MAIL_SETTINGS_DIR`'certs')
define(`confCACERT_PATH', `CERT_DIR')
define(`confCACERT', `CERT_DIR/CAcert.pem')
define(`confSERVER_CERT', `CERT_DIR/mycert.pem')
define(`confSERVER_KEY', `CERT_DIR/mykey.pem')
define(`confCLIENT_CERT', `CERT_DIR/mycert.pem')
define(`confCLIENT_KEY', `CERT_DIR/mykey.pem')

7. Create certificate directory:

sudo mkdir /etc/mail/certs
cd /etc/mail/certs

8. Create SSL certificate:

sudo openssl dsaparam 1024 -out dsa1024 -out dsa1024.pem
sudo openssl req -x509 -nodes -days 3650 -newkey dsa:dsa1024.pem -out /etc/mail/certs/mycert.pem -keyout /etc/mail/certs/mykey.pem
sudo ln -s /etc/mail/certs/mycert.pem /etc/mail/certs/CAcert.pem
sudo openssl req -x509 -new -days 3650 -key /etc/mail/certs/mykey.pem -out /etc/mail/certs/mycert.pem

9. Change file permission of all files to 600:

sudo chmod 600 *

10. Change “/etc/mail/certs” directory to 700:

cd ..
sudo chmod 700 certs

11. Run “make”:

sudo make

12. Reload “sendmail”:

sudo /etc/init.d/sendmail reload

13. That’s it!