I used python to count the students who did not submit homework in the class, and sent them emails with one click. I have received many private messages from people. Here I will share with you how to send files using python.
Without further ado, let’s go straight to the code:
import zmail
def mail(str):
mail_server = zmail.server(username='你的邮箱号', password='你邮箱的授权码')
mail = mail_server.get_latest()
# file_path = 'homework.jpg'
mail_info = {
'subject': '爱你么么哒',
'content_text': str,
# 'attachments': file_path,
}
mail_server.send_mail('你要发送的人的邮箱', mail_info)
if __name__ == '__main__':
text = '爱你么么哒'
mail(text)
As for how to obtain the authorization code, you can search it yourself. There are a lot of online tutorials, so I won’t go into details.