932
edits
Changes
Merging 4C into 4B.
[[Image:Email-servers.png]]
=== Services involved in email delivery ===
* When sending an email, you send it to the destination using your MTA, but you also want to save it in your '''"Sent"''' folder for yourself. This is accomplished by a separate connection to your '''IMAP''' or '''POP3''' server.
** Thus, a situation can occur that although you sent your email successfully, it may never make it to your "Sent" folder - the <u>second</u> connection to your IMAP server is quite unrelated to the first connection to the '''SMTP''' server.
* Note that a DNS server is also involved - it is needed to retrieve the address of the email server responsible for email for a particular domain. This is done with the MX records we looked at in the DNS labs. ===Online References=== * [https://inside.senecacollege.ca/its/services/email/email_clients/imap.html Seneca Client Settings] (Seneca Server settings for mail client - Thunderbird)* [https://help.ubuntu.com/community/Dovecot Dovecot Community Documentation]* [https://www.debian-administration.org/article/275/Setting_up_an_IMAP_server_with_dovecot Setting up an IMAP Server with Dovecot]
=== Install Thunderbird Application and Setup a Reference Client ===
<ol><li value="3">After you create your '''Thunderbird''' account, you should be able to read your existing email and send new email within the Thunderbird application.</li><li>Take time to view your ''Account Settings'' and ''Preferences'' to get a feel for what settings exist. For example:<ul><li>How often will Thunderbird check for new messages?</li><li>Will the messages you write be in HTML or plain text?</li><li>How do you change your SMTP server settings? Why are they in a different section?</li></ul></li></ol>
The main objective of this section was to learn how to setup your Thunderbird application to read your Seneca email, so in the next section you can use the exact type of setup for your own email server.
== INVESTIGATION 1: SETTING UP MTA FOR RECEIVING EMAIL ==
#The Edit the '''/etc/postfix/main.cf''' application should be installed by default. If it isn't, install itfile.#Install also Scroll down to the '''netstat''' application (tipline containing: use yum search to find the package name) and also install the '''telnetmydestination''' command.#Postfix will work with the default configuration, so start and enable this service, and verify that the postfix service is running.#Look for change line to the running postfix service in the list of listening ports by issuing the following commandtext shown below:<br><source lang="bash">netstat -atnp</source>#Which service is postfix running? Locate the port used by SMTP, and look for connctions with the state LISTEN (i.e. currently listening).#Write your observations in your lab logbook.
<pre>mydestination === Testing the connection to the Postfix Service ===$mydomain, $myhostname, localhost.$mydomain, localhost</pre>
=== Listening on all interfaces Installing and Configuring the Local Delivery Agent (LDA) ===
'''Perform the following steps:'''
# Launch Dovecot is not installed when you installed your Virtual machines in editing session for previous labs.#Install the Dovecot application by issuing the postfix configuration file calledfollowing command: '''<br>yum install dovecot#Edit your /etc/postfix/main.cffile and scroll down to (or search for) '''# Change the value of mailbox_command'''. Add the following parameter to what is displayed belowline: inet_interfaces = all
<olpre><li valuemailbox_command ="3">We should also set the string that will end up in the '''From:''' header in messages sent by this server. Change '''mydomain''' to your domain name and '''myorigin''' to '''$mydomain'''.</li><li>Restart the postfix service and confirm (using netstat) that the service is now listening on <u>all<usr/u> interfaces (not just loopback)<libexec/li><li>Test by connecting to it (using telnet) from your '''host''' machine.<dovecot/li>dovecot-lda -f "$SENDER" -a "$RECIPIENT"</olpre>
==INVESTIGATION 2: SETUP THUNDERBIRD MAIL USER AGENT (MUA) FOR YOUR VIRTUAL NETWORK (vm2, vm3) ==
'''Perform the following steps:'''
<ol><li value="3"> Use the "Advanced config" button to bypass that check.</li><li>Use the Thunderbird application to send an email to your myseneca address. If you've done everything right, it will send the message successfully, but it will fail to save it in the Sent folder since that's done with IMAP and you don't have an IMAP server yet.</li><li>Verify that your message has been sent. Check your myseneca email and look at '''/var/log/maillog''' on vm2 (your email server).</li></ol>
=== Sending a Mail Message from VM2 (Using Thunderbird)===
{{Admon/important |Sent messages will not be saved to the sent folder|During this step the messages you send will not be saved to the sent folder and Thunderbird will permanently hang with a message that it is saving the message. It will never succeed, as we have not yet configured the imap server to accept the connection necessary for that to work.}}
'''Perform the following steps:'''
#Use the '''ss''' and '''nc''' commands (like you did in lab 4b) to confirm your service is listening on the correct ports/interfaces. You will probably have to open the appropriate firewall port on '''vm3''' to allow incoming '''SMTP''' connections.<br><br>'''Note:''' You should be able to send email to any regular user <u>on</u> '''vm3''' using the email address '''yourusername@yoursenecaid.org''' using the Thunderbird application on your host machine (which is configured to use the account on your vm2).<br><br>
<ol><li value="2">Create a new account on your '''vm3''' machine using only your <u>first</u> name. We will use this account as a one-time "test" if the mail message has been received on your VM3 machine (from your VM2 machine).<br><br>'''Note:''' It is <u>'''important'''</u> that you '''<u>don't</u>''' create this same account name on your vm2 machine, since you want to easily identify the difference between the sending and receiving SMTP servers.<br><br></li></ol>
<ol><li value="3">We still haven't set up IMAP (for reading email) but we can test that the message is being delivered. Use the new account in Thunderbird to send an email to '''firstname@yoursenecaid.org''' and then check the contents of '''/home/firstname/Maildir/new/''' on your '''vm3''' machine. There should be a file there with the contents of your email.</li><li>If there is no file, then check the log file '''/var/log/maillog''' to see what went wrong.</li><li>If you can see a file in the '''/home/firstname/Maildir/new/''' directory, then review the procedures on how you got the email server working (since you have performed many steps and set up many services).</li><li>Refer to the diagram at the top of this lab. Which services have you currently set up? Record your findings in your lab Logbook.</li></ol>
{{Admon/important |Encountering error messages when sending email|If you cannot properly receive sent e-mail messages, check the '''/var/log/syslog''' file for errors.<br><br> If you locate an error message in that file such as: '''Fatal: Error reading configuration: Invalid settings...''', then add the following <u>parameter</u> in '''/etc/dovecot/dovecot.conf''':<br>'''postmaster_address at DOMAIN''' (where DOMAIN is actually <u>your</u> domain).<br><br>After you have saved those changes, then '''restart''' your dovecot service.}}
=== Viewing Received Mail Message on VM3 VIA IMAP (Using Thunderbird) ===
Finally, we will set up the IMAP server so we can read email. The current way we have configured our mail server on our VM3 machine should allow all the email for anyaccount@yoursenecaid.org should be delivered to our '''vm3''' machine. We will set up Dovecot (with IMAP, IMAPS in the next lab) to get easy access to that email.
'''Perform the following steps:'''
#The configuration file for the Dovecot service (which is not the same thing as dovecot-lda) is: '''/etc/dovecot/dovecot.conf'''. Modify the '''protocols''' option so that Dovecot will work with IMAP connections, no POP3 or LMTP.
# Start the dovecot service, and ensure it will always start automatically when the machine boots.
# Use the '''ss''' command to confirm the service is listening, and use nc on the host to confirm you can connect to it.
#If you can connect - it's now time to do something wrong, that is connect to our IMAP server using Thunderbird over an unencrypted connection.
# Edit the '''/etc/dovecot/conf.d/10-auth.conf''' file and set '''disable_plaintext_auth''' to '''no'''.
# Then edit the '''/etc/dovecot/conf.d/10-ssl.conf''' file and set '''ssl''' to '''yes'''.<br><br>'''Note:''' This combination of parameters will allow your username and password to be sent over the internet in plain text, for anyone interested to look at. In the following lab we'll set up secure SMTP and IMAP connections, for now this is all we have time for.<br><br>
# Restart dovecot so the changes take effect.
#Try to connect to your IMAP server with Thunderbird by clicking on your '''Inbox'''.
#If nothing happens, then check the Thunderbird Activity Manager for any errors. If the connection is successful, you should see the '''Trash''' box <u>appear</u> below Inbox.
# Finally, send an email message from '''yoursenecaid@yoursenecaid.org''' to '''yoursenecaid@yoursenecaid.org''' using the Thunderbird application. The mail message should be sent without errors, and you should notice a '''Sent''' folder appear in the list. If all worked well, you should see your message arrive in the '''Inbox''' and you know that your configuration works correctly.
'''Record steps, commands, and your observations in INVESTIGATION 2 in your OPS335 lab log-book'''
== COMPLETING THE LAB ==
'''Depending on your professor you will either be asked to submit the lab in class, or online. Follow the appropriate set of instructions below'''
===Online Submission===
Follow the instructions for lab 4b on moodle.
===In Class Submission===
Students should be prepared with '''all required commands (system information) displayed in a terminal (or multiple terminals) prior to calling the instructor for signoff'''.
==EXPLORATION QUESTIONS==
# What is the purpose of the Thunderbird application?
# List the steps to configure your DNS to temporarily allow your Thunderbird application to connect to your mail server.# What is the purpose of the '''Dovecot''' package?# What is the purpose of the '''mydestination''' parameter contained in the '''/etc/postfix/main.cf''' file?# Why are '''IMAP''' and '''POP''' email servers placed on separate machines (vms)?# What is the purpose of the '''mail_location''' parameter contained in the '''/etc/dovecot/conf.d/10-mail.conf''' file?