Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help please in python from socket import * import 331 import base 64 # Message to send msg = ' Hey There! Im sending this
Help please in python
from socket import * import 331 import base 64 # Message to send msg = ' Hey There! Im sending this email from Python via Sockets!' endmsg = ' ' # Choose a mail server (e.g. Google mail server) and call it mailserver mailserver = 'smtp.gmail.com' or 'smtp.office365.com' for outlook e.g. SBU mail server # TO DO:Create socket called client Socket and establish a TCP connection with mailserver # Connect to the mail server through the Port number may change according to the mail server. SMTP Default is 587 for gmail and outlook for use by mail clients client Socket.connect((mailserver, 587)) #Receive the response through the socket and decode it conResponse = client Socket.recv(1024).decode() # To Do:Print the received information # WHAT IS THE MEANING OF SMTP STATUS CODE 220? if conResponse[:3] != '220': print('220 reply not received from server.') # Send HELO command and print server response. helloCommand = 'HELO gmail.com ' #To Do: Send your encoded hello command via your socket #Receive the response through the socket and decode it helloResponse = client Socket.recv(1024).decode() #To Do:Print the received information #WHAT DOES THE STARTTLS COMMAND Do? client Socket.send('STARTTLS '.encode()) tlsResponse = client Socket.recv(1024).decode() print (tls Response) #Wrap the socket around a secure TLS connection context = 331.create_default_context() context = 331. SSLContext (331. PROTOCOL_TLS) client Socket = context.wrap_socket (client Socket) #Send an authentication command to login to mail server client Socket.send('AUTH LOGIN '.encode()) loginResponse = client Socket.recv(1024).decode() print (loginResponse) #If command was successful the server responds with a status code and message (334 VXNlcm5hbWU6) #WHAT IS THE MEANING OF THE ABOVE STATUS CODE AND MESSAGE? #Another status code and message is also displayed (334 UGFzc3dvcmQ6) #WHAT IS THE MEANING OF THE ABOVE STATUS CODE AND MESSE #Send the base64 eoncoded login credentials to the mail server # To Do: Replace 'your_user_name' with your actual email user client Socket.send (base64.b64encode(('your_user_name').encode())) client Socket.send(' ').encode()) # To Do: Replace 'your_password' with your actual email Password client Socket.send (base64.b64encode(('your_password').encode())) client Socket.send((' ').encode()) # Send MAIL FROM command and print server response. # To Do: Replaced 'your_gmail_address with your actual Gmail address mailfrom = 'MAIL FROM:Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started