Mail

From Unix Wiki
Jump to: navigation, search

Common mail problems

In case if your IP's have been banned by GOOGLE, YAHOO and other mail servers you need to unban them on following site: The Spamhaus Project

Postfix example:

Nov 19 16:42:08 SERVER postfix/smtp[4413]: 29C888178C: to=<XXXXXXXX@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.143.27]:25,
delay=3.1, delays=0.11/0.01/1.9/1.1, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[74.125.143.27] said: 550-5.7.1 [YOUR_BANNED_IP]
The IP you're using to send mail is not authorized to 550-5.7.1 send email directly to our servers. Please use the SMTP relay at your 550-5.7.1
service provider instead. Learn more at 550 5.7.1 http://support.google.com/mail/bin/answer.py?answer=10336 fd9si4433606lbb.29
(in reply to end of DATA command))

Sendmail

Sendmail forward user outgoing mail to smartrelay

This action plan has been designed and tested during SR16636.

1) Uncomment in following strings in /etc/mail/sendmail.mc

FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl

2) Add following strings in /etc/mail/sendmail.mc

FEATURE(`smarttable')dnl
define(`RELAY_MAILER',`relay')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
FEATURE(`genericstable',`hash -o /etc/mail/genericstable.db')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/generics-domains')dnl
  • You can also comment in EXPOSED_USER(`root')dnl directive for testing, because by default, user 'root' will not be masqueraded.

3) Add following string to /etc/mail/access

AuthInfo:smtp.example.com "U:isp_provided_mailbox@isp_domain.com" "P:<PASSWORD>" "M:LOGIN" 
  • Last parameter - auth method.

4) Create smarttable file in /etc/mail/ with following lines:

user@customer_domain.com relay:smtp.example.com

5) Create genericstable file in /etc/mail/ with following lines:

user isp_provided_mailbox@isp_domain.com

6) Create generics-domains file in /etc/mail with following lines:

localhost
localdomain
localhost.localdomain
customer_domain.com

7) Download smarttable for m4

# wget http://anfi.homeunix.org/sendmail/smarttable.m4
# cp smarttable.m4 /usr/share/sendmail-cf/feature/

8) cd /etc/mail, then hash and make

# makemap hash smarttable <smarttable
# makemap hash genericstable <genericstable
# makemap hash access <access
# make

9) Restart sendmail service

# service sendmail restart

Useful links::

Send mail via Telnet interface

1. Connect to smtp server:

# telnet localhost 25
Trying 192.168.0.92...
Connected to localhost (192.168.0.92).
Escape character is '^]'.
220 localhost ESMTP Sendmail

2. Writting your mail (need to put that line at your telnet interface and press enter at the end of each line)

HELO localhost
MAIL FROM:you@server
RCPT TO: you@server.com
DATA
SUBJECT: <Your subject> (after that press <cr> twice and write your mail body)

To queue your mail move to next line, enter dot (.) and press enter. After that you may see this

Message accepted for delivery

or even this

250 2.0.0 Ok: queued as 1994E1C7601


Mutt

.muttrc send mail via specified SMTP

~/.muttrc:

set envelope_from = "yes"
set smtp_url = "smtp://USER@DOMAIN.COM@DOMAIN.COM:25/"
set smtp_pass = "PASSWORD"
set realname="solrec11 Server"
set from="reports@solluco.co.za"
set use_from=yes
set ssl_starttls = no
set ssl_use_sslv3 = no
set ssl_use_tlsv1 = no

delete mail older than X days

mutt -f Maildir -e 'push D~d>Xd\rq\n'

Where X is the number of days.

Elastix

SMTP auth relay

Default elastix configuration doesn't support relaying using postfix auth Following diff represents difference between default config and working config. postconf -e can be used for configuration.

433c433
< smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination
---
> smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
437c437
< smtpd_sasl_auth_enable = no
---
> smtpd_sasl_auth_enable = yes
441c441
< smtpd_sasl_path = smtpd
---
> smtpd_sasl_path = private/auth

Postfix

Office365

relayhost = [smtp.office365.com]:587
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
sender_canonical_maps = regexp:/etc/postfix/generic
smtp_generic_maps = hash:/etc/postfix/smtp_generic_maps
smtp_sasl_auth_enable = yes
debug_peer_list = smtp.office365.com
smtp_use_tls=yes
smtp_sasl_security_options = noanonymous
inet_protocols = ipv4
# cat /etc/postfix/sasl_passwd
[smtp.office365.com]:587 username@domain.com:Password
# tail -n1 /etc/postfix/generic
/.*/    username@domain.com
# cat /etc/postfix/smtp_generic_maps
/.*/    username@domain.com
# postmap /etc/postfix/sasl_passwd; postmaep /etc/postfix/smtp_generic_maps