Difference between revisions of "Mail Tips"

From Wiki
Jump to: navigation, search
(Filtering Email)
(Filtering Email)
Line 93: Line 93:
   $h_X-Barracuda-Spam-Flag: is "YES"
   $h_X-Barracuda-Spam-Flag: is "YES"
   save "/home/albertav/mail/albertaventure.com/gblodgett/.spam/" 660
   save "/home/user/mail/example/mailuser/.spam/" 660

Latest revision as of 18:26, 22 December 2015


Disable catchall address for all users without one:

cd /etc/valiases/
for x in *; do sed -i -e "s/\*:\s\w*\w*$/\*: :fail: no such address here/" $x; done

Clean up cpanel comet files:

From time to time you may see a server with a large amount of space used by the /root/.cpanel directory, this is usually caused by stale comet files created by cPanel.  To fix this run this command.

Empty catchall inboxes (mbox):

for i in `ls /home`; do cat /dev/null > /home/$i/mail/inbox; done

SPF Example:

domain.com. IN TXT "v=spf1 a mx ~all"

Send mail using telnet:

telnet mail.domain.ext 25

You should receive a reply like:
Trying ???.???.???.???...
Connected to mail.domain.ext.
Escape character is '^]'.
220 mail.domain.ext ESMTP Sendmail ?version-number?; ?date+time+gmtoffset?

You will then need to delcare where you are sending the email from:

HELO local.domain.name - dont worry too much about your local domain name although you really should use your exact fully qualified domain name as seen by the outside world the mail server has no choice but to take your word for it as of RFC822-RFC1123.

This should give you:
250 mail.domain.ext Hello local.domain.name [loc.al.i.p], pleased to meet you

Now give your email address:
(On many mailservers the space after the : is required rather that optional. Thanks to Justing Goldberg)

MAIL FROM: mail@domain.ext

Should yeild:

250 2.1.0 mail@domain.ext... Sender ok
If it doesn't please see possible problems.

Now give the recipients address:

RCPT TO: mail@otherdomain.ext

Should yeild:
250 2.1.0 mail@otherdomain.ext... Recipient ok

If it doesn't please see possible problems.

To start composing the message issue the command DATA

If you want a subject for your email type Subject:-type subject here- then press enter twice (these are needed to conform to RFC 882)

You may now proceed to type the body of your message (e.g. hello mail@otherdomain.ext from mail@domain.ext)

To tell the mail server that you have completed the message enter a single "." on a line on it's own.

The mail server should reply with: 250 2.0.0 ???????? Message accepted for delivery

You can close the connection by issuing the QUIT command.

The mailserver should reply with something like:221 2.0.0 mail.domain.ext closing connection

Connection closed by foreign host.

Send mail from the command line:

sendmail -t < test.eml

Filtering Email

Exim supports PCRE for filter files. For example:

# Exim filter

if not first_delivery and error_message then finish endif

 $header_subject: matches "(?i)\\\\b(cialis|ambien|prozac|viagra|penis)\\\\b"
 or $message_body: matches "(?i)\\\\b(cialis|ambien|prozac|viagra|penis)\\\\b"
  save "/dev/null" 660

Filters can match *any* header. For example, to filter out spam you can set up a user level filter by editing the /home/username/etc/domain/mailuser/filter file as follows.

 #Mailsecure tagged messages
  $h_X-Barracuda-Spam-Flag: is "YES"
  save "/home/user/mail/example/mailuser/.spam/" 660

For more details see the documentation at http://www.exim.org/exim-html-3.10/doc/html/filter_toc.html

To test a filter using the sendmail -bf command:

sendmail -bf /etc/vfilters/<domain> < test.eml

Mozilla Thunderbird

If you see an error in Thunderbird regarding weak Diffie-Hellman parameters you will need to generate a new pem file and then restart courier-imap or dovecot. You may also see an error in the mail logs similar to below.

host imapd-ssl: couriertls: accept: error:14094417:SSL routines:SSL3_READ_BYTES:sslv3 alert illegal parameter

This line will be repeated any time that Thunderbird tries to use TLS.

cd /usr/lib/courier-imap/share
mv dhparams.pem dhparams.pem.old
openssl dhparam -out dhparams.pem 2048
chmod 600 dhparams.pem
service courier-imap restart

Filtering mail using BESS

For customers that use BESS you will need to set up a custom route in the exim configuration manager.

Add the following right below ROUTERSTART in Advanced Exim configuration:

driver = manualroute
domains = ! +local_domains
transport = remote_smtp
route_list = * d71260.o.ess.barracudanetworks.com

Force Exim to use TLS for outgoing mail

To make exim use TLS for outgoing mail you will need to set up a custom router and a custom transport. This can be done in the advanced configuration manager.

begin routers

    driver = accept
    domains = secure.mail.com
    transport = tls_smtp

begin transports

    driver = smtp
    hosts_require_tls = * 

Related Links

Mutt manual - http://www.mutt.org/doc/manual/manual-4.html