Mail Systems
From Alessandro's Wiki
exim
- configuring first install of exim in Debian/Ubuntu
dpkg-reconfigure exim4-config
- General type of mail configuration: internet site; mail is sent and received directly using SMTP
- System mail name: <the FQDN of the host>
- IP-addresses to listen on for incoming SMTP connections: 127.0.0.1
- Other destinations for which mail is accepted: <blank>
- Domains to relay mail for: <blank>
- Machines to relay mail for: <blank>
- Keep number of DNS-queries minimal (Dial-on-Demand)? No
- Delivery method for local mail: mbox format in /var/mail/
- Split configuration into small files? No
commands
- see the queue:
mailq
- or
exim -bp
the output shows the message queue giving useful information to work with it:
root:~# mailq
24h 379 1QC8cA-0001iy-B3 <ciaotest@server.company>
hellobye@server.company.nl
*; 1QC8cA-0001iy-B3: message ID (corresponds to a filename)
*; 24h : time msg spent in the queue
*; 379: the size in bytes.
- find a queued message:
find /var/spool/ -name "1QC8cA-0001iy-B3*"
- to un-queue messages, I delete the files found by the find command (to rude maybe?)... it works
- flush the queue:
runq
- or
exim -q
- flush queue forcing frozen messages to be sent
exim -qf
- flush queue forcing frozen/non-frozen messages to be sent
exim -qff
- Prints run time configuration:
exim4 -bP
- testing relay emulating a host:
/usr/sbin/exim -bh 192.168.1.1
mail from:info@domain.com rcpt to:webmaster@otherdomain.com
configuration
- this options will make exim act as a secondary MX of anyone listing your server in the DNS :
domainlist relay_to_domains = @mx_secondary
- this uses a file instead:
domainlist relay_to_domains = ${lookup{$domain}partial-lsearch{/etc/relay_to_domains}}
postfix
command line
- enabling SMTP relay:
Restriction list name Status Effect of REJECT or DEFER result smtpd_client_restrictions Optional Reject all client commands smtpd_helo_restrictions Optional Reject HELO/EHLO information smtpd_sender_restrictions Optional Reject MAIL FROM information smtpd_recipient_restrictions Required Reject RCPT TO information smtpd_data_restrictions Optional Reject DATA command smtpd_end_of_data_restrictions Optional Reject END-OF-DATA command smtpd_etrn_restrictions Optional Reject ETRN command
show queue
mailq
flush the mail queue
postfix flush
remove all the mail from the queue (delete it)
postsuper -d ALL
find email address in queue
(postsuper manual)
for a in `mailq | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "service@visaitalia.com" && $9 == "") print $1 } ' | tr -d '*!'`; do echo "---$a";ls -l ./*/$a; done;
mailq | tail -n +2 | awk 'BEGIN { RS = "" } / info@mail\.com$/ { print $1 }' | tr -d '*!' | postsuper -d -
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / info@email\.net/ { print $1 }' | tr -d '*!' | postsuper -d -
re-process the queue
postqueue -f
- or...
pfqueue
canonical rewrite
vi /etc/postfix/canonical
femmes:~# postmap /etc/postfix/canonical
- unix user e-mail
domain-name name@domain.com
- generating a report and sending it:
/usr/sbin/sendmail -v <an e-mail>
configuration
#mynetworks = hash:/etc/postfix/network_table #relay_domains = $mydestination #relayhost = $mydomain alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases #home_mailbox = Maildir/ debug_peer_level = 2 #debug_peer_list = 127.0.0.1 #header_checks = regexp:/etc/postfix/header_checks
Dovecot
configuration
Troubleshoot
ssl enabled, but ssl_cert not set
- get rid of those "<" characters !!!
OpenPEC2
- developers stopped supporting the software and any company involved in the development has no working website anymore
- documentation (very poor): http://openpec.sourceforge.net/doc_instopec.shtml
- download https://sourceforge.net/projects/openpec/
- the code is outdated and not in line with libSSL1.1. To make it work today (october 2020) I had to install a second copy of libSSL in the syestem (so 1.0 + 1.1) very dirty solution
https://packages.debian.org/jessie/amd64/libssl-dev/download https://packages.debian.org/jessie/amd64/libssl1.0.0/download
dpkg -i libssl1.0.0_1.0.1t-1+deb8u12_amd64.deb dpkg -i libssl-dev_1.0.1t-1+deb8u12_amd64.deb
- Debian repo dependencies:
apt install libtest-net-ldap-perl libio-stringy-perl libunix-syslog-perl libsys-sigaction-perl libnet-httpserver-perl libmime-tools-perl zlib1g-dev
- Perl deps. (this will not compile with libSSL >= 1.1
cpan Crypt::SMimeEngine
mailman
- show all lists
/var/lib/mailman/bin/list_lists
- show pending messages
/var/lib/mailman/bin/show_qfiles /var/lib/mailman/qfiles/shunt/*.pck
- re-queque shunted messages
/var/lib/mailman/bin/unshunt # on another terminal tail -f /var/log/mail.log
- find the parent list of an address:
for lista in `/usr/lib/mailman/bin/list_lists -b`; do /usr/lib/mailman/bin/list_members $lista|grep <indirizzo> && echo $lista; done
virtual hosts
- in the file:
/etc/mailman/mm_cfg.py