Difference between revisions of "OPS335 Lab 4c"

From CDOT Wiki
Jump to: navigation, search
Line 76: Line 76:
 
'''Perform the following steps:'''
 
'''Perform the following steps:'''
  
#Use the '''netstat''' and '''telnet''' 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 vm2 machine.
+
#Use the '''netstat''' and '''telnet''' 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 vm2 machine.<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.</li></ol>
+
<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>
  
 
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 vm3. - there should be a file there with the contents of your email.
 
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 vm3. - there should be a file there with the contents of your email.

Revision as of 16:11, 11 March 2016

LAB RESOURCES

Online References:


OVERVIEW (RECEIVING EMAIL)

Last week, we configured and run the Postfix application (MTA a.k.a. SMTP server) on our VM2 machine.

We also installed and configured a graphical Mail User Agent (MUA) called Thunderbird to test the connection to the running MTA by sending an email message to your myseneca email account.


The a diagram below (duplicate to lab 4b) shows your basic setup of your email system:


Email-servers.png

This week, we will set up a Postfix demonstration for receiving email on your VM3 machine.

You may ask yourself, "why not install on VM2 machine, since we used the VM2 machine in the previous lab?". The reason for this approach is to separate the two types of services: IMAP vs POP3.

We will begin by using the existing Postfix service on your VM3 machine, then add an Local Delivery Agent (LDA) by installing the dovecot-lda package, configure it, and test ti to make sure that is is working correctly.

Finally, we will set up an IMAP server (Dovecot) so you can read your email from an MUA such as Thunderbird or a Webmail (we will set up a webmail application in a later lab).


Important.png
Set up MX Record in your DNS Server
If you haven't already done it - set up an MX record in your DNS server to make vm3.yoursenecaid.org the server responsible for receiving emails for anyuser@yoursenecaid.org (vm3 will be used for receiving, vm2 for sending only).


INVESTIGATION: SETTING UP MTA FOR RECEIVING EMAIL

Specifying Which Domains are Used to Delivered the "Received" Mail Messages

The default job of an SMTP server is to forward the message received to another email server. We performed that step in the previous lab: in other words, your postfix MTA receives an email from your MUA (Thunderbird) and forwards it to the destination SMTP server.


The other thing an SMTP server can be configured to do is receive email. Your SMTP server, in this case, forwards the received mail message to another SMTP server, which in turn, forwards it to the Local Delivery Agent (LDA).

This is done using postfix by setting the mydestination parameter (configuration variable) to include $mydomain (this is assuming you've set up mydomain, myorigin , and inet_interfaces the same way as in the previous lab).

Perform the following steps:

  1. Edit the /etc/postfix/main.cf file.
  2. Scroll down to the line containing: mydestination and change line to the text shown below:
mydestination = $mydomain, $myhostname, localhost.$mydomain, localhost
Note: Even though your machine's name is vm2.yoursenecaid.org, your postfix MTA will also receive emails addressed to the domain called: yoursenecaid.org

Installing and Configuring the Local Delivery Agent (LDA)

Postfix is capable of performing the function of an LDA, but its LDA capabilities are limited, thus postfix is generally not used for that purpose. Currently, the most popular LDA is LMTP, but we will be installing, configuring and using an LDA called Dovecot since it is also popular and we will later be setting up Dovecot as an IMAP server. Using both Postfix and Dovecot will actually increase the performance of our IMAP server.

Perform the following steps:

  1. Dovecott is not installed when you installed your Virtual machines in previous labs.
  2. Install the Dovecott application by issuing the following command:
    yum install dovecot-lda
  3. Edit your /etc/postfix/main.cf file and scroll down to (or search for) mailbox_command. Add the following line:
mailbox_command = /usr/libexec/dovecot/dovecot-lda -f "$SENDER" -a "$RECIPIENT"
NOTE: Do not replace any variables, those are set automatically by Postfix when it runs the LDA. If you are interested in learning more about the Dovecot application, you can read about dovecot-lda here and here (i.e. optional reading for interest only).
  1. Finally, edit the /etc/dovecot/conf.d/10-mail.conf file and indicated where you want your mail delivered by including the following line
mail_location = maildir:~/Maildir
  1. Restart your postfix service. Note that dovecot-lda is just a program invoked by Postfix, it doesn't have an associated service.

Sending a Mail Message from VM2 (Using Thunderbird)

Perform the following steps:

  1. Use the netstat and telnet 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.

    Note: You should be able to send email to any regular user on vm3 using the email address yourusername@yoursenecaid.org using the Thunderbird application on vm2 machine.

  1. Create a new account on your vm3 machine using only your first 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).

    Note: It is important that you don't create this same account name on your vm2 machine, since you want to easily identify the difference between the sending and receiving SMTP servers.

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 vm3. - there should be a file there with the contents of your email.

If there isn't one - check the log file /var/log/maillog to see what went wrong.

If you got it - this is a good time to stop and ponder how it all worked. You've gone through setting up a lot of services. Look at the diagram at the top of the page - which services have you set up?

Viewing Received Mail Message on VM3 VIA IMAP (Using Thunderbird)

Finally we'll set up the IMAP server so we can read email. The way we've set it up - all the email for anyaccount@yoursenecaid.org should end up on vm3. We will set up Dovecot (with IMAP, IMAPS in a later lab) to get easy access to that email.

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.

Use netstat to confirm the service is listening, and use telnet 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 /etc/dovecot/conf.d/10-auth.conf and set disable_plaintext_auth to no. Then edit /etc/dovecot/conf.d/10-ssl.conf and set ssl to yes. 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.

To try connect to your IMAP server with Thunderbird - click on your Inbox. If nothing seems to happen - check the Thunderbird Activity Manager for any errors. If the connection is successful - you should see a Trash show up below Inbox.

Finally - send an email from yoursenecaid@yoursenecaid.org to yoursenecaid@yoursenecaid.org using Thunderbird. The message should go out without errors, you should see a Sent folder appear in the list, and you should see your message arrive in the inbox. If all that happend - your setup is correct.

COMPLETING THE LAB

Students should be prepared with all required commands (system information) displayed in a terminal (or multiple terminals) prior to calling the instructor for signoff.

Arrange evidence (command output) for each of these items on your screen, then ask your instructor to review them and sign off on the lab's completion:

Thunderbird with a message sent and received.
Thunderbird server configuration for your account.
Logs on vm2 and vm3 showing the message has been sent and received.


EXPLORATION QUESTIONS