Learning Python Network Programming

(Sean Pound) #1

Engaging with E-mails


In the authentication phase, the authentication data is sent by the client-side
script with the help of the login() method. Note that the authentication token is a
base-64 encoded string and the username and password are separated by a null byte.
There other supported authentication protocols exists for the sophisticated clients.
The following is the example of authentication token:


send: 'AUTH PLAIN A...dvXXDDCCD.......sscdsvsdvsfd...12344555\r\n'


reply: b'235 2.7.0 Accepted\r\n'


reply: retcode (235); Msg: b'2.7.0 Accepted'


After the client is authenticated, it can send e-mail messages by using the
sendmail() method. Three arguments are passed to this method, sender, recipient,
and the message. The sample output is shown here:


send: 'mail FROM:[email protected] size=360\r\n'


reply: b'250 2.1.0 OK xw9sm8487512wjc.24 - gsmtp\r\n'


reply: retcode (250); Msg: b'2.1.0 OK xw9sm8487512wjc.24 - gsmtp'


send: 'rcpt TO:[email protected]\r\n'


reply: b'250 2.1.5 OK xw9sm8487512wjc.24 - gsmtp\r\n'


reply: retcode (250); Msg: b'2.1.5 OK xw9sm8487512wjc.24 - gsmtp'


send: 'data\r\n'


reply: b'354 Go ahead xw9sm8487512wjc.24 - gsmtp\r\n'


reply: retcode (354); Msg: b'Go ahead xw9sm8487512wjc.24 - gsmtp'


data: (354, b'Go ahead xw9sm8487512wjc.24 - gsmtp')


send: 'Content-Type: multipart/mixed;
boundary="===============1501937935=="\r\nMIME-Version: 1.0\r\n


To: -===============1501937935==--\r\n.\r\n'


reply: b'250 2.0.0 OK 1414235750 xw9sm8487512wjc.24 - gsmtp\r\n'


reply: retcode (250); Msg: b'2.0.0 OK 1414235750 xw9sm8487512wjc.24 -
gsmtp'


data: (250, b'2.0.0 OK 1414235750 xw9sm8487512wjc.24 - gsmtp')


You email is sent to [email protected].


send: 'quit\r\n'


reply: b'221 2.0.0 closing connection xw9sm8487512wjc.24 - gsmtp\r\n'


reply: retcode (221); Msg: b'2.0.0 closing connection
xw9sm8487512wjc.24 - gsmtp'

Free download pdf