1.3.0 Email
You can send emails useing the SMTP protocol (SMTP stands for Simple Mail Transfer Protocol), to raed the recieved emails you can use the POP3 and IMAP4 protocols.
Let's start with the SMTP protocol:
1.3.1 SMTP
The SMTP protocol is used to send emails via a smtp-server. As the smtp protocol wasn't enough anymore the ESMTP protcol was created (Extended SMTP).
Let's start with connecting to a smtp-server:
import smtplib
smtp = smtplib.SMTP('smtp.example.com')
First we import the smtp module,then we connect to a smtp-server (btw,the address doesn't always start with the protocol name,because sometimes the server has an other name (e.g. 'mail.example.com').
Like at FTP we also have to login to our email account:
smtp.login('myusername','mypass')
Sending mails looks a bit more complex:
smtp.sendmail('from','to','message'[,mailoptions,rctpoptions])
For example a simple email:
smtp.sendmail('mymail@mail.com','friendsmail@othermail.com','Hello World')
Or with more receiver:
smtp.sendmail('mymail@mail.com',['firendsmail@othermail.com','fiend2smail@example.com'],'Hellow World')
To quit use:
smtp.quit()
(I'll show you a very basic smtp-client after the email-module)
POP3 and IMAP4 will come soon...