Python for Entrepreneurs Transcripts
Chapter: Course Conclusion
Lecture: Lightning review: Sending email

Login or purchase this course to watch this video and the rest of the course contents.
0:01 We have our mailing list, but there's other times, there's, let's call them user actions or user events
0:08 where we might want to directly send mail out of our application. So we leverage the mailer package for this
0:15 to set up a really simple way to send email and then we just create an instance of this mailer here, right,
0:22 set the host, port, username, password, things like this. So these events might be the user forgot their password and they're asking for a reset,
0:30 or they've created a new account, or they purchased something, things like that. And then, once we have this smtp sender thing,
0:37 we can go and create a message, you just set the standard things you would
0:41 if you were to type that out yourself, the from, to, and so on, you set the subject; the thing where it got interesting was we set the HTML body
0:47 and then we use HTML to text also set the plain text body in case for some reason they set their email client to only read plan text.
0:56 So this is kind of a really nice automatic way to do it and then we just cal smtp.send, and off it goes.

Talk Python's Mastodon Michael Kennedy's Mastodon