SMTP
● SMTP stands for Simple Mail Transfer Protocol
● This protocol is used for sending emails over the internet
● It is a text based protocol that works with the other email protocols
such as POP3 (Post Office Protocol) and IMAP (Internet Message
Access Protocol).
● POP3: It is the standard protocol used by email clients to retrieve
messages from mail servers.
● It is most used for email retrieval
● It also allows an email client to download messages from mail server
to local system like personal computer
● IMAP: It is the standard protocol used by email clients to retrieve
and send messages from mail server
● It also allows multiple devices to access and manage the same
mailbox in a synchronised manner.
1. Purpose of SMTP:
● SMTP is designed for sending mails from client to a server or
between servers
● It is not storing any emails that is handled by POP3 and IMAP
protocols
● And SMTP uses port 25
Configuration of SMTP Server:
STEP 1: Update the server
STEP 2: Install Postfix:
● Postfix is an open-source Mail Transfer Agent that routes and delivers email
messages.
STEP 3: Start and enable the postfix service
And check the status
STEP 4: Install mailx
● In RHEL mailx package is replaced by s-nail package
● It is a command-line-based email client that provides a set of tools for
sending, receiving, and managing email from the terminal.
STEP 5: Edit the Postfix config file using vim editor
Command: vim /etc/postfix/[Link]
● Add hostname of my server
● Add Domain name of my server
● Uncomment this line
● Uncomment this line
● Comment this line
● Comment this line
● Uncomment this line
● Add my network ip address subnet
● Uncomment this line
● Add the following lines in config file
smtp_tls_security_level = may
This setting specifies the security level for TLS (Transport Layer Security) when
communicating with other mail servers. Setting it to "may" means that if the remote
server supports TLS, then Postfix will attempt to use it.
relayhost = [[Link]]:587
This setting defines the relay host, which is the mail server to which Postfix will
forward all outgoing emails.
smtp_use_tls = yes
This option enables the use of TLS when connecting to the relay host.
smtp_sasl_auth_enable = yes
Enables SASL (Simple Authentication and Security Layer) authentication. This is
necessary when authenticating to the Gmail SMTP server to send emails on behalf of
a Gmail account.
smtp_sasl_security_options =
This setting specifies additional security options for SASL authentication. Leaving it
empty means that default security options will be used.
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
This line points to a file (/etc/postfix/sasl_passwd) that contains the username and
password for authenticating to the Gmail SMTP server.
smtp_tls_CAfile = /etc/pki/tls/certs/[Link]
The smtp_tls_CAfile parameter in the Postfix configuration specifies the location of the
file containing the trusted certificate authorities (CAs) that are used to verify the
identity of the remote SMTP server when establishing a TLS (Transport Layer
Security) encrypted connection.
STEP 6: Restart the Postfix service
STEP 7: Add user and Passwd:
STEP 8 : telnet command is used to establish communication with remote
computer or server over a TCP/IP network
STEP 9: Verify whether Postfix is working or not by executing the
commands below
STEP 10: verify the mail
STEP 11: To check the mail logs use below command
tail: This command is used to display the last part of the file.
-f : This option is used to display the new lines as they are added to the
file
/var/log/maillog: This is path to the mail log file
STEP 12: Now generate App Password in gmail account
● Go to gmail account and click on security and enable 2 step
verification
● And then scroll down last in 2 step verification so we find App
Password and click on generate and password will generate
STEP 13: Give necessary permissions
STEP 14: Generate a Mail