sendmail dh key too small
Tue, 08/04/2015 - 21:17 — sandipLogjam broke Sendmail?
Generate new DH keys file:
cd /etc/pki/tls/certs
openssl dhparam -out dhparams.pem 2048
Edit sendmail.mc:
define(`confDH_PARAMETERS' ;,`/etc/pki/tls/certs/dhparams .pem')dnl
Update sendmail.cf and restart:
cd /etc/mail
make
service sendmail restart
Refer to https://weakdh.org/sysadmin.ht
Get a count of top 10 emails that are in mail queue
Wed, 12/01/2010 - 16:55 — sandipBelow one liner, pipes mailq command to sed, which prints out every 3rd line starting from line 5 capturing only the email addresses and producing report of the top 10 email addresses in sendmail mail queue.
mailq | sed -n '5~3p' | sort | uniq -c | sort -nr | head
- sandip's blog
- Login or register to post comments
Migrating Sendmail Mail Server
Sat, 10/02/2010 - 00:13 — sandipBelow is how I have migrated mail server with minimum downtime and routing mail to the new server via mailertable, if IP is still pointing to the old server and has not resolved for some ISPs.
-
48 hours prior to migration, set the TTL value for the mail server DNS A record to a short time like 15 minutes.
Prepare for the migration, rsycing the mail spool folder and the user home mail folders.
rsync --progress -a -e "ssh -i /root/.ssh/key -p 22" old.mailserver:/var/spool/mail / /var/spool/mail/
rsync --progress -a -e "ssh -i /root/.ssh/key -p 22" old.mailserver:/var/www/web1/m ail/ /var/www/web1/mail/
rsync --progress -a -e "ssh -i /root/.ssh/key -p 22" --exclude='*/bak' --exclude='*/web' old.mailserver:/var/www/web1/u ser/ /var/www/web1/user/
Run rsync the final time.
Setup Sendmail with mailertable to relay mail coming in to the old server over to the new mail server. This is a similar setup for secondary mail servers.
Add "FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl"
Create "/etc/mail/mailertable" file with contents of the routing table:
domain.tld esmtp:[xxx.xxx.xxx.xxx]
The square brackets skips checking MX records, so IP can be used instead. Remove domain name from "/etc/mail/local-host-names" so mails do not get delivered locally.
Edit "/etc/mail/access" to relay mail for the domain.
TO:domain.tld RELAY
cd /etc/mail
makemap hash access.db < access
makemap hash mailertable.db < mailertable
Test by telneting to port 25 on the old servers' IP and sending email. This should get relayed over to the new server.
Use a new subdomain and redirect existing webmail url to the new server.
- sandip's blog
- Login or register to post comments
resend all mails in sendmail queue
Sun, 07/11/2010 - 23:31 — sandipAs root you can redeliver all mail in the mail server queue via:
sendmail -v -q
- sandip's blog
- Login or register to post comments
Using a .forward to send mail to multiple accounts
Thu, 05/06/2010 - 14:00 — sandipIf you put multiple addresses in a .forward file, a copy will be sent to each.
remoteuser1@domain.tld, remoteuser2@domain.tld, remoteuser3@domain.tld
If you want to keep a copy of each message in the original account without causing a .forward infinite loop, put a backslash in front of the account name.
\localuser, remoteuser1@domain.tld, remoteuser2@domain.tld, remoteuser3@domain.tld
- sandip's blog
- Login or register to post comments
Relay email via SMTP provider using sendmail
Wed, 12/16/2009 - 00:02 — sandipThe below is specific to CentOS-5.4 and may work similarly with other distros.
-
Additional packages required if not installed already:
Edit ”/etc/mail/sendmail.mc”:sendmail-cf
m4
make
cyrus-sasl-plain
define(`SMART_HOST', `{smtprelay.domain.tld}') dnl
FEATURE(`authinfo',`has h -o /etc/mail/authinfo.db')dn l
AuthInfo:smtprelay.domain.tld "U:{username}" "P:{password}" "M:PLAIN"
cd /etc/mail
make
Now mails sent to localhost is relayed via your SMTP provider.
- sandip's blog
- Login or register to post comments
- Read more
Rewriting Sender addresses for Entire Domain in Sendmail
Sun, 06/28/2009 - 23:13 — sandip-
Edit /etc/mail/sendmail.mc and add the below lines replacing domain.tld with the actual domain name:
dnl # BEGIN: Rewriting Sender addresses for Entire Domain
dnl #
dnl # Process login names through the genericstable
FEATURE(`genericstable' , `hash -o /etc/mail/genericstable.db 9;)dnl
dnl # Interpret the value in G as a domain name
FEATURE(generics_entire_doma in)dnl
dnl # masquerade not just the headers, but the envelope as well
FEATURE(masquerade_envelope) dnl
dnl # Load domain.tld into G
GENERICS_DOMAIN(domain.tld)d nl
dnl #
dnl # END: Rewriting Sender addresses for Entire Domain
web1_user1 user1@domain.tld
web1_user2 user2@domain.tld
web1_user3 user3@domain.tld
# makemap -hash /etc/mail/genericstable < /etc/mail/genericstable
Feature "genericstable" tells sendmail to use the generics table.
Feature "generics_entire_domain" allows to add hosts to genericstable without having to rebuild sendmail.cf.
Feature "masquerade_envelope" applies the rewriting process to the mail envelope as well as to the mail header.
"GENERICS_DOMAIN" defines the domains to which you wish to apply the generics table.
- sandip's blog
- Login or register to post comments
- Read more
sendmail use of clientmqueue and mqueue folders
Tue, 04/28/2009 - 10:31 — sandipWhen submitting mail by using sendmail as a mail submission program, sendmail copies all messages to "/var/spool/clientmqueue" first. Sendmail is a setgid smmsp program and thus gives any user the permission to do so (/var/spool/clientmqueue belongs to user and group smmsp). Later, another sendmail process, the sendmail mail transfer agent (MTA) copies the messages from /var/spool/clientmqueue to /var/spool/mqueue and sends them to their destination.
/var/spool/clientmqueue is thus the holding area used by the MSP (Mail Submission Protocol) sendmail instance before it injects the messages into the main MTA (Mail Transport Agent) sendmail instance.
Sendmail will save the message in /var/spool/clientmqueue for safe keeping before trying to connect to the MTA to get the message delivered. Normally there would be a 'queue runner' MSP sendmail instance which every half hour would retry sending any message that couldn't be sent immediately. Each message will generate a 'df' (message routing info) and 'qf' (message headers and body) file. You can list out all of the messages and their status by:
# mailq -v -Ac
When files accumulate in /var/spool/clientmqueue, this is probably due to sendmail localhost MTA not running, and thus the mails don't get send.
Sendmail tips
Sun, 06/22/2008 - 22:41 — sandip-
Backup files:
/etc/mail/sendmail.mc
/etc/mail/sendmail.cf
/etc/mail/access
/etc/mail/access.db
/etc/aliases
Security enhancements:
-
Require a HELO or EHLO greeting from the sending SMTP server.
Put limits on Sendmail forks and other settings to stop a DOS attack from overwhelming server.
Munge the Sendmail server identification.
Recipient throttle to identify when an envelope arrives with more than 4 invalid users, presuming that this is a dictionary attack.
Limit the number of recipients in a single message.
dnl #
dnl #start security mods
define(`confPRIVACY_FLAGS 39;, `authwarnings,novrfy,noexpn,re strictqrun,needmailhelo') dnl
define(`confMAX_DAEMON_CHILD REN',20)dnl
define(`confSMTP_LOGIN_MSG 039;,$j Sendmail; $b)dnl
define(`confMIN_FREE_BLOCKS& #039;, `4000')dnl
define(`confMAX_HEADERS_LENG TH', `32000')dnl
define(`confMAX_MIME_HEADER_ LENGTH', `1024')dnl
define(`confBAD_RCPT_THROTTL E',`4')dnl
define(`confMAX_RCPTS_PER_ME SSAGE', `10')
dnl #end security mods
dnl #
Enable DNS BlockLists:
dnl #
dnl # Begin Spam Block Enhancement mod
dnl # Start BlockList
FEATURE(`dnsbl', `bl.spamcop.net', `"554 Spam blocked - see http://spamcop.net/bl.shtml?&q uot;$&{client_addr}') dnl
FEATURE(`dnsbl', `zen.spamhaus.org', `"554 Rejected - see http://www.spamhaus.org/query/ bl?ip="$&{client_addr }')dnl
dnl # sorbs dynamic user list ( not dial up )
FEATURE(`dnsbl', `dul.dnsbl.sorbs.net', `"554 Rejected "$&{client_addr}" ; - see http://dnsbl.sorbs.net" 039;)dnl
dnl # End BlockList
dnl # Start dont bounce errors back to me
define(`confDOUBLE_BOUNCE_AD DRESS', `dev-null')dnl
dnl # End dont bounce
dnl # Start delay checks, so we see the intended recipient
dnl # Added friend so we can exempt specified local user via access file
FEATURE(`delay_checks', `friend')dnl
dnl # End delay checks
dnl # End Spam Block Enhancement mod
dnl #
All of the above should go before the line:
FEATURE(`blacklist_recipients& #039;)dnl
Notes:
The above Double Bounce Address throws the double bounces into the bit bucket.
The delay_checks feature causes it to log the sender from address and other info, when it rejects spam.
Create an alias in "/etc/aliases" called dev-null and point it to "/dev/null":dev-null: /dev/null
Connect:xxx.xxx.xxx.xxx OK
where xxx.xxx.xxx.xxx is the server IP. This keeps you from blocking yourself, if you happen to get listed in one of the blocklists used!
To apply the configurations, run:# newaliases
# makemap hash /etc/mail/access.db < /etc/mail/access
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# /sbin/service sendmail restart
- sandip's blog
- Login or register to post comments
Debugging sendmail
Fri, 06/20/2008 - 16:01 — sandipThe -b switch instructs sendmail to "Become"/operate in a mode.
The -d0 switch, instructs sendmail to produce debugging information.
The level .11 prints more information than the default level of .1 .
The -bp switch instructs sendmail to print the contents of the queue.
$ sendmail -d0.11 -bp
You can verify aliases with the -bv switch:
$ sendmail -bv root
To run sendmail verbosely, use the -v switch:
$ cat /dev/null | sendmail -v root