How to Send Mail
Posted: 24 Dec 2007, 13:00
Hi,
This how-to describes the setup of postfix for sending mail using an external SMTP server.
NOTE: this how-to is now also available on the wiki http://wiki.excito.org/wiki/index.php/S ... MTP-server
My ISP has a SMTP server available, for which i need (of course) to authenticate, using username and password.
Below is the configuration I will be using during the how-to, please replace it with your own.
Install the packages, using the Debian sources, see Howto install Debian packages (http://forum.excito.net/viewtopic.php?t=421)
Setup
Edit the /etc/postfix/main.cf
Look for the parameter relayhost and fill in your preferred smtp server
Add the following parameters at the end
Create the sasl password file
Add the following contents
Convert the file to a hash format
Check the above command by running a simple "hash" key test
Mapping
Optional: Mapping local email address to valid Internet addresses.
I created an account eek on the bubba and get default the email address eek@bubba.excito.com.
But my ISP knows me by eek@myisp.com, so i need to map the email addresses.
My postfix version is
For version 2.1 and earlier, do the following:
Edit the /etc/postfix/main.cf
Add the following parameters at the end
Create the canonical file, which maps outgoing mail to a given email address
Add the following contents
Create the virtual file, which maps incoming mail to a given email address
Add the following contents
Convert the files to a hash format
Restart
Restart postfix
To see if all changes went into effect, run postconf -n
Test if the mail is getting delivered
Login as eek
Send mail
Check the logfile if the mail got handed to the smtp server
Have Fun.
References
This how-to describes the setup of postfix for sending mail using an external SMTP server.
NOTE: this how-to is now also available on the wiki http://wiki.excito.org/wiki/index.php/S ... MTP-server
My ISP has a SMTP server available, for which i need (of course) to authenticate, using username and password.
Below is the configuration I will be using during the how-to, please replace it with your own.
Packagessmtp server : smtp.myisp.com
username : eek
password : thecat
mailuser at myisp.com : eek@myisp.com
mailuser on bubba : eek@bubba.excito.com
Install the packages, using the Debian sources, see Howto install Debian packages (http://forum.excito.net/viewtopic.php?t=421)
Code: Select all
apt-get install postfix-tls
apt-get install libsasl2-modules
Edit the /etc/postfix/main.cf
Code: Select all
vi /etc/postfix/main.cf
Code: Select all
relayhost = [smtp.myisp.com]
Code: Select all
smtpd_sasl_auth_enable = no
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtpd_sasl_local_domain = $myhostname
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtpd_sasl_application_name = smtpd
Code: Select all
vi /etc/postfix/sasl_passwd
Code: Select all
# Contents of sasl_passwd
#
[smtp.myisp.com] eek:thecat
Code: Select all
postmap /etc/postfix/sasl_passwd
Protect your password so only root can read the file.$ postmap -q [smtp.myisp.com] /etc/postfix/sasl_passwd
eek:thecat
Code: Select all
chmod 640 /etc/postfix/sasl_passwd
Optional: Mapping local email address to valid Internet addresses.
I created an account eek on the bubba and get default the email address eek@bubba.excito.com.
But my ISP knows me by eek@myisp.com, so i need to map the email addresses.
My postfix version is
For version 2.2 and later, you can use a generic file, see reference 4.$ postconf mail_version
mail_version = 2.1.5
For version 2.1 and earlier, do the following:
Edit the /etc/postfix/main.cf
Code: Select all
vi /etc/postfix/main.cf
Code: Select all
canonical_maps = hash:/etc/postfix/canonical
virtual_alias_maps = hash:/etc/postfix/virtual
Code: Select all
vi /etc/postfix/canonical
Code: Select all
eek@bubba.excito.com eek@myisp.com
Code: Select all
vi /etc/postfix/virtual
Code: Select all
eek@myisp.com eek@bubba.excito.com
Code: Select all
postmap /etc/postfix/canonical
postmap /etc/postfix/virtual
Restart postfix
Code: Select all
/etc/init.d/postfix restart
Test$ postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
canonical_maps = hash:/etc/postfix/canonical
config_directory = /etc/postfix
disable_vrfy_command = yes
home_mailbox = Mail/
inet_interfaces = all
mailbox_size_limit = 0
mydestination = $myhostname $mydomain localhost.$mydomain localhost
mydomain = localdomain
mynetworks_style = subnet
myorigin = /etc/mailname
recipient_delimiter = +
relayhost = [smtp.myisp.nl]
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_helo_required = yes
smtpd_recipient_restrictions = permit_mynetworks reject_unauth_destination reject_unauth_pipelining reject_invalid_hostname reject_non_fqdn_sender reject_unknown_sender_domain reject_non_fqdn_recipient reject_unknown_recipient_domain reject_rbl_client list.dsbl.org reject_rbl_client relays.ordb.org reject_rbl_client dnsbl.njabl.org reject_rbl_client dnsbl.sorbs.net reject_rbl_client bl.spamcop.net permit
smtpd_sasl_application_name = smtpd
smtpd_sasl_auth_enable = no
smtpd_sasl_local_domain = $myhostname
virtual_alias_maps = hash:/etc/postfix/virtual
Test if the mail is getting delivered
Login as eek
Code: Select all
su - eek
Code: Select all
echo "Test mail" | mail -s "This is a test mail" eek@myisp.com
Check if you've got mail!$ cat /var/log/mail.log
Dec 24 17:33:18 bubba postfix/postfix-script: starting the Postfix mail system
Dec 24 17:33:18 bubba postfix/master[5100]: daemon started -- version 2.1.5
Dec 24 17:33:58 bubba postfix/pickup[5104]: A45EA11F043A: uid=1001 from=<eek>
Dec 24 17:33:58 bubba postfix/cleanup[5111]: A45EA11F043A: message-id=<20071224173358.A45EA11F043A@bubba.localdomain>
Dec 24 17:33:58 bubba postfix/qmgr[5105]: A45EA11F043A: from=<eek@myisp.com>, size=338, nrcpt=1 (queue active)
Dec 24 17:33:59 bubba postfix/smtp[5113]: A45EA11F043A: to=<eek@myisp.com>, relay=smtp.myisp.nl[222.111.6.66], delay=1, status=sent (250 2.0.0 lBOGYki1012247 Message accepted for delivery)
Dec 24 17:33:59 bubba postfix/qmgr[5105]: A45EA11F043A: removed
Have Fun.
References