In this task, you will be implementing a python-based simple mail client, which can send email to any recipient. Your email client should connect to a mail server and communicate using the SMTP protocol.
Note: You are not allowed to use the smtplib
python library.
Using sockets, connect to campus SMTP mail server. Then implement the smtp conversations in the python program myUtepEmailClient
which will contact with the server to send your email to "[email protected]".
- From Microsoft's website, the following settings are used for UTEP's Office365 SMTP settings:
- Server: smtp.office365.com
- Domain: 1417249971.mail.outlook.com (from the NSLOOKUP command for domain
miners.utep.edu
) - Port: 587
- Encryption: STARTTLS
- To create the mail client, I followed this Python socket tutorial to better understand the socket commands
- For the syntax on socket communications when it comes to logging in to an SMTP mail server, I used this resource on SMTP commands to format my commands.
- However, there arose some issues when connecting to UTEP's domain mail server:
- when starting TLS (encrypted connection)
- does UTEP have issues because of SSO?
- likely no if I can access the
miners.utep.edu
domain
- likely no if I can access the
- or is it a setting I'd need to contact tech support/admin for? (see this for more information)
- all search results lead to this being the issue when attempting to login to my UTEP account through SMTP lines of communication (both on the command and in the scripts in this project)
- in fact, the issue was in my sequence of calls to securing the connection:
STARTTLS
must be sent to the server once the client establishes the secure TLS connection in order to make the handshake- then, re-connecting to the domain with the secure connection allowed the client to progress to the next stage of authentication
- Connecting to UTEP's VPN allows the client to successfully log in with UTEP credentials, with the username including the
miners.utep.edu
full domain.
Using sockets, connect to a popular webmail server, like AOL mail server. Then perform the same task as Part-I and implement the smtp conversations in the python program myExternalEmailClient.py
which will contact with the SMTP server to send your email to "[email protected]".
- From Microsoft's website, the following settings are used for AOL's SMTP settings:
- Server: smtp.aol.com
- Domain: mx-aol.mail.gm0.yahoodns.net (from the NSLOOKUP command for domain
smtp.aol.com
) - Port: 587
- Encryption: TLS
- From Microsoft's website, the following settings are used for GMail's SMTP settings:
- Server: smtp.gmail.com
- Domain: dns-admin.google.com (from the NSLOOKUP command for domain
smtp.gmail.com
) - Port: 587
- Encryption: TLS
- In addition to the commands list in Part 1, to connect to
smtp.aol.com
server,- I used this page for the examples of commands in SMTP communications
- I fixed my bug in logging in by following the solution to this page to debug my
AUTH PLAIN
errors and ended up usingAUTH LOGIN
for more security - I also followed the instructions in this page to see if I can actually send an email through SMTP on the command line.
For the security aspect of this assignment, I followed these steps to allow for a secure TLS connection:
- I used the Python SSL library to secure the connection with TLS encryption
- This Microsoft page helped me to find the locations of all certificates on my system
- But, instead of hard-coding the location, I used the
load_default_certs()
method of the Python SSL library. This requires creating a (default) context (instead of using the deprecatedwrap_socket()
function).
- On the server side, this requires removing 2FA (2 Factor Authentication) on accounts. Settings must also have Less Secure App Access enabled.
- I could not adjust the settings for my AOL account (security options were not available to me in my new account) and therefore could not send an email through it.
- But with GMail this was able to be completed and emails were successfully sent and received.