Email WeeSan Lee <weesan@cs.ucr.edu> http://www.cs.ucr.edu/~weesan/cs183/ Roadmap Introduction Mail System Architecture Email Headers Sendmail Debugging Aliases Forwarding Procmail Q&A Introduction MUA Eudora MUA Outlook MTA (port 25) The Internet MTA (port 25) LDA procmail MUA mail MUA pine MSA (port 587) Message store MUA mail MUA pine AA Imapd, pop3 Introduction (cont) A mail system consists of: MUA – Mail User Agent Lets users read and compose email, eg. Mail, Pine, Eudora, Outlook MTA – Mail Transport Agent Routes emails among machines, eg. Sendmail, Postfix Speaks SMTP (Simple Mail Transport Protocol) Question: What are the MSA – Mail Submission Agent differences between Accepting emails from MUA, eg. Sendmail POP3 and IMAP? LDA – Local Delivery Agent Places emails to a local message store, eg. Procmail /var/spool/mail/username AA – Access Agent Connects MUA to message store, eg. POP3, IMAP Mail System Architecture Incoming SMTP server Outgoing SMTP server For sending outgoing emails IMAP or POP3 server For accepting incoming emails with spam filters For retrieving emails Message Store /var/spool/mail/username /home/username/mail/INBOX E-mail Header Attribute: value Eg. Header starts with X- will be ignored, eg. From: weesan@cs.ucr.edu Bcc: bill.gates@microsoft.com X-Spam-Flag: YES Body 7-bit ASCII text Question: How are binary data sent over emails? Sendmail Both a MTA (port 25) and MSA (port 587) Configuration file /etc/mail/sendmail.cf Mail queue /var/spool/mqueue/ Debugging mail $ cal | mail -s “test” weesan@cs.ucr.edu sendmail -oi -t $ cat | sendmail -oi –t From: weesan@cs.ucr.edu To: bill.gates@microsoft.com Subject: Hi Bill Linux is better -WeeSan ^D Debugging (cont) telnet $ telnet mail.cs.ucr.edu 25 … 220 esmtp.cs.ucr.edu ESMTP Postfix mail from: weesan@cs.ucr.edu 250 Ok rcpt to: bill.gates@microsoft.com 250 Ok data 354 End data with <CR><LF>.<CR><LF> Subject: Hi Bill Linux is better :) . 250 Ok: queued as F1C832AFBE4 quit 221 Bye Connection closed by foreign host. /etc/aliases or /etc/mail/aliases Allows users to be referred by multiple names Used by mailing list $ cat /etc/aliases | grep weesan root: weesan, weesan@email.com To rehash aliases $ newaliases ~/.forward $ cat ~/.forward \weesan weesan@email.com ~/.procmailrc # For spam :0 * (^Subject:.*\[SPAM\]|X-Spam-Flag: YES) INBOX.spam # Another type of spam :0 * ^From:.*bill.gates@microsoft.com /dev/null ~/.procmailrc # SMS myself :0 c * ^From:.*myboss@ucr.edu | (formail -c -XFrom: -XSubject: ; echo "To: $MY_CELL") | $SENDMAIL -oi -t ~/.procmailrc # UCR Systems support emails :0 * ^Subject:.*(New Ticket|Ticket Assigned) { :0 c INBOX.systems :0 | (formail -c -XFrom: -XSubject: ; echo "To: $MY_CELL") | $SENDMAIL -oi -t } Reference LAH Ch 18: Electronic Mail http://www.sendmail.org/ http://www.procmail.org/ http://www.imap.org/