Elektronick?? po??ta

Daniel Za??ovi??, 469348@mail.muni.cz

SMTP protokol

SMTP je textov?? protokol nad TCP na porte 25. [1] Po naviazan?? TCP spojenia, server za??le svoju identifik??ciu, na ??o klient po??le HELLO s n??zvom svojej dom??ny. MAIL FROM ??pecifikuje n??vravov?? adresu (return-path/bounce address/reverse path/envelope from).

S: 220 smtp.example.com ESMTP Postfix
C: HELO relay.example.com
S: 250 smtp.example.com, I am glad to meet you
C: MAIL FROM:<bob@example.com>
S: 250 Ok
C: RCPT TO:<alice@example.com>
S: 250 Ok
C: RCPT TO:<theboss@example.com>
S: 250 Ok
C: DATA
S: 354 End data with <CR><LF>.<CR><LF>
C: From: "Bob Example" <bob@example.com>
C: To: Alice Example <alice@example.com>
C: Cc: theboss@example.com
C: Date: Tue, 15 Jan 2008 16:02:43 -0500
C: Subject: Test message
C: 
C: Hello Alice.
C: This is a test message with 5 header fields and 4 lines in the message body.
C: Your friend,
C: Bob
C: .
S: 250 Ok: queued as 12345
C: QUIT
S: 221 Bye
{The server closes the connection}

From??t spr??vy

Emailov?? hlavi??ka mus?? obsahova?? minim??lne polia From a Date. From obsahuje mail a pr??padne meno autora mailu. Nemus?? zodpoveda?? skuto??n??mu odosielate??ovi (MAIL FROM) Date obsahuje lok??lny ??as odosielate??a pri odoslan??. ??al??ie polia m????u by?? [2]:

Zoznam v??etk??ch pol?? je dostupn?? na str??nke IANA-y. [3]

MIME

Pr??tomnos?? hlavi??ky MIME-Version signalizuje, ??e spr??va je MIME-formatovan??.

Content-Transfer-Encoding m????e ma?? hodnoty:

MIME-Version: 1.0
X-Mailer: MailBee.NET 8.0.4.428
Subject: test subject
To: kevinm@datamotion.com
Content-Type: multipart/mixed;
       boundary="XXXXboundary text"
 
--XXXXboundary text
Content-Type: multipart/alternative;
       boundary="XXXXboundary text"
 
--XXXXboundary text
Content-Type: text/plain;
       charset="utf-8"
Content-Transfer-Encoding: quoted-printable
 
This is the body text of a sample message.
--XXXXboundary text
Content-Type: text/html;
       charset="utf-8"
Content-Transfer-Encoding: quoted-printable
<pre>This is the body text of a sample message.</pre>

--XXXXboundary text
Content-Type: text/plain;
name="log_attachment.txt"
Content-Disposition: attachment;
filename="log_attachment.txt"
Content-Transfer-Encoding: base64

TUlNRS1WZXJzaW9uOiAxLjANClgtTWFpbGVyOiBNYWlsQmVlLk5FVCA4LjAuNC40MjgNClN1Ympl
Y3Q6IHRlc3Qgc3ViamVjdA0KVG86IGtldmlubUBkYXRhbW90aW9uLmNvbQ0KQ29udGVudC1UeXBl
OiBtdWx0aXBhcnQvYWx0ZXJuYXRpdmU7DQoJYm91bmRhcnk9Ii0tLS09X05leHRQYXJ0XzAwMF9B
RTZCXzcyNUUwOUFGLjg4QjdGOTM0Ig0KDQoNCi0tLS0tLT1fTmV4dFBhcnRfMDAwX0FFNkJfNzI1
RTA5QUYuODhCN0Y5MzQNCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsNCgljaGFyc2V0PSJ1dGYt
OCINCkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IHF1b3RlZC1wcmludGFibGUNCg0KdGVzdCBi
b2R5DQotLS0tLS09X05leHRQYXJ0XzAwMF9BRTZCXzcyNUUwOUFGLjg4QjdGOTM0DQpDb250ZW50
LVR5cGU6IHRleHQvaHRtbDsNCgljaGFyc2V0PSJ1dGYtOCINCkNvbnRlbnQtVHJhbnNmZXItRW5j
b2Rpbmc6IHF1b3RlZC1wcmludGFibGUNCg0KPHByZT50ZXN0IGJvZHk8L3ByZT4NCi0tLS0tLT1f
TmV4dFBhcnRfMDAwX0FFNkJfNzI1RTA5QUYuODhCN0Y5MzQtLQ0K

--XXXXboundary text--

[4]

??lenenie mail softw??ru

Ukladanie mailov

DNS MX z??znam

@ IN MX 10 mail.foo.bar.
@ IN MX 20 backup.foo.bar.
;
mail IN CNAME server1
backup IN A 192.168.0.2
server1 IN A 192.168.0.1

[6]

Konfigur??cia sendmail

Potrebujeme nain??talova?? sendmail a m4 na generovanie konfigura??n??ch s??borov. Ka??d?? u????vate?? mus?? ma?? lok??lny ????et, vytvor??me pomocou useradd -m -s /usr/bin/nologin username Vytvor??me s??bor /etc/mail/sendmail.mc, pr??klad konfigur??cie

include(`/usr/share/sendmail-cf/m4/cf.m4')
define(`confDOMAIN_NAME', `your-domain.com')dnl
FEATURE(use_cw_file)
dnl  The following allows relaying if the user authenticates,
dnl  and disallows plaintext authentication (PLAIN/LOGIN) on
dnl  non-TLS links:
define(`confAUTH_OPTIONS', `A p y')dnl
dnl
dnl  Accept PLAIN and LOGIN authentications:
TRUST_AUTH_MECH(`LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `LOGIN PLAIN')dnl
dnl
dnl Make sure this paths correctly point to your SSL cert files:
define(`confCACERT_PATH',`/etc/ssl/certs')
define(`confCACERT',`/etc/ssl/cacert.pem')
define(`confSERVER_CERT',`/etc/ssl/certs/server.crt')
define(`confSERVER_KEY',`/etc/ssl/private/server.key')
dnl
FEATURE(`virtusertable', `hash /etc/mail/virtusertable.db')dnl
OSTYPE(linux)dnl
MAILER(local)dnl
MAILER(smtp)dnl

Potom nech??me s??bor spracova??: m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Nastav??me dom??ny, ktor?? tento server obsluhuje v /etc/mail/local-host-names

localhost
your-domain.com
mail.your-domain.com
localhost.localdomain

Nastav??me, odkia?? dovol??me preposiela?? maily v s??bore /etc/mail/access

10.5.0 RELAY
127.0.0 RELAY

Potom nech??me s??bor spracova??: makemap hash /etc/mail/access.db < /etc/mail/access Do s??boru /etc/mail/aliases m????eme prida?? aliasy vo form??te

469348:      xzatovic
469430:      xnovak

a spracujeme pr??kazom newaliases.

V s??bore /etc/mail/virtusertable sa d?? konfigurova?? mapovanie z mena a dom??ny na konkr??tneho lok??lneho u????vate??a.

your-username@your-domain.com         your-username
joe@my-other.tk                       joenobody

Spracujeme pr??kazom makemap hash /etc/mail/virtusertable.db < /etc/mail/virtusertable. [7]

Literat??ra

  1. https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol

  2. https://en.wikipedia.org/wiki/Email#Internet_Message_Format

  3. https://www.iana.org/assignments/message-headers/message-headers.xhtml

  4. https://kb.datamotion.com/?ht_kb=what-does-a-sample-mime-message-look-like

  5. Essential System Administration: Tools and Techniques for Linux and Unix Administration, 3rd Edition

  6. https://fedoraproject.org/wiki/Administration_Guide_Draft/DNS

  7. https://wiki.archlinux.org/index.php/Sendmail

  • Arch??v refer??t??