compose mails Mail Transport Agent (MTA) Route mails among machines Delivery Agent (DA) Place mails in users’ mail boxes Access Agent (AA) Connects the user agent to the mail Submission Agent (SA) Route mails to local MTA box using POP or IMAP protocols 4
compose mails Mail Transport Agent (MTA) Route mails among machines Delivery Agent (DA) Place mails in users’ mail boxes Access Agent (AA) Connects the user agent to the mail Submission Agent (SA) Route mails to local MTA box using POP or IMAP protocols 5
mail from UA, examine the recipients’ addresses, and delivery the mail to the correct host Protocols SMTP (Simple Mail Transport Protocol) RFC 821 ESMTP (Extended SMTP) RFC 1869, 1870, 1891, 1985 Popular transport agents sendmail http://www.sendmail.org/ Postfix http://www.postfix.org/ 7
to mailserver.domain. Escape character is '^]'. 220 mailserver.domain ESMTP Sendmail 8.13.8/8.13.8 HELP 214-2.0.0 This is sendmail version 8.13.8 214-2.0.0 Topics: 214-2.0.0 HELO EHLO MAIL RCPT DATA 214-2.0.0 RSET NOOP QUIT HELP VRFY 214-2.0.0 EXPN VERB ETRN DSN AUTH 214-2.0.0 STARTTLS 214-2.0.0 For more info use "HELP <topic>". 214 2.0.0 End of HELP info HELO mailclient 250 mailserver.domain Hello mailserver.domain [192.168.11.1], pleased to meet you QUIT 221 2.0.0 mailserver.domain closing connection Connection closed by foreign host. 9
When you want to send the mail to [email protected], the MTA will: First, lookup up the mail exchanger of “eating.domain” $ dig mx eating.domain ;; ANSWER SECTON: eating.domain. 7200 IN MX 5 mx2.eating.domain. eating.domain. 7200 IN MX 10 mx1.eating.domain. eating.domain. 7200 IN MX 5 mx3.eating.domain. If there is any MX records, choose the higher preference(lower MX) one If this preferred one can not be connected, choose another If all the MX servers can not be connected (or not available), mail it directly to the host 10
envelope Invisible to users Determine where the message should be delivered, or to whom it The headers Information about the messages, defined in RFC822 should be returned From, To, Date, Time, MTA, ... The message body Plain text only Various MIME contents are encoded as printable characters using radix-64 algorithm 13 The Letter
Added by mail.local when the mail is put in user’s mailbox Used to separate message boundary Return-Path: [email protected] Used to send the error message to this address May be different to the “From” address Received: from knecht.sendmail.org (localhost [127.0.0.1]) by knecht.sendmail.org (8.9.3/8.9.2) with ESMTP id GAA18984; Fri 1 Oct 1999 06:04:02 -800 (PST) Every machine that is ever processed this mail will add a “Received” record in top of headers Sending machine Receiving machine Version of sendmail in receiving machine Message unique identifier in receiving machine Date and time 17
(8.9.3/8.9.2) with ESMTP id HAA21741 for <[email protected]>; Fri, 1 Oct 1999 07:04:25 -0700 (MST) Received: from mroe.cs.colorado.edu (mroe.cs.colorado.edu [128.138.243.1]) by anchor.cs.colorado.edu (8.9.3/8.9.2) with ESMTP id HAA26176 for <[email protected]>; Fri, 1 Oct 1999 07:04:24 -0700 (MST) Received: from knecht.sendmail.org (knecht.sendmail.org [209.31.233.160]) by mroe.cs.colorado.edu (8.9.3/8.9.2) with ESMTP id HAA09899 for <[email protected]>; Fri, 1 Oct 1999 07:04:23 -700 (MST) Received: from knecht.sendmail.org (localhost [127.0.0.1]) by knecht.sendmail.org(8.9.3/8.9.2) with ESMTP id GAA18984; Fri 1 Oct 1999 06:04:02 -800 (PST) 18
un-specified, postfix will use ‘hostname’ command mydomain mydomain = eating.domain If un-specified, postfix use myhostname minus the first component mydestination List all the domains that postfix should accept for local delivery mydestination = $myhostname, localhost.$mydomain, $mydomain This is the situation that mx will route mail to mailgate mydestination = $myhostname, localhost.$mydomain 38
permit anyone to relay mails By default, postfix is not an open relay A mail server should Relay mail for trusted user Relay mail for trusted domain 39
= subnet Allow relaying from other hosts in the same subnet mynetworks_style = host Allow relaying for only local machine mynetworks_style = class Any host in the same class A, B or C Restricting relay access by mynetworks List individual IP or subnets in network/netmask notation Ex: in /etc/postfix/mynetworks 127.0.0.0/8 140.115.0.0/16 10.113.0.0/16 Relay depends on what kind of your mail server is 40
From: Eating<[email protected]> Subject: SMTP Example This is a testing mail. . 250 2.0.0 Ok: queued as EBD0C81AC189 QUIT 221 2.0.0 Bye Connection closed by foreign host. 45
Subject: SMTP Example This is a testing mail. . 250 2.0.0 Ok: queued as EBD0C81AC189 QUIT 221 2.0.0 Bye Connection closed by foreign host. 連線 SMTP 46 Body Header