Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Talking About Other Providers

00:00 In the previous lesson, I showed you how to connect over SSL and authenticate to a Gmail server. In this lesson, I’ll talk about some of the other providers out there.

00:09 Google may sometimes feel like the only choice, but there are others. A popular one in the development community is Proton Mail. It’s privacy-focused and includes end-to-end encryption.

00:21 The tools are based on open source, but it is a commercial product. It does have limited free accounts for testing, but you can’t use their SMTP server unless you’re a paying client.

00:32 Another option is Posteo. They’re similar to Proton, but one of their claims to fame is they use 100% green energy in their data centers. Like Gmail, Posteo supports app passwords, which saves you having to figure out OAuth.

00:48 Not only are there other providers, but there are other libraries as well. Yagmail is a Gmail-specific client, which connects via OAuth 2, so no need for an app password.

00:59 Does mean you’ve got to figure out how to associate keys with your account, though. Yagmail supports using your operating system’s key rings, which reduces the amount of password typing you need to do once you’ve got everything set up.

01:11 Unfortunately, this library hasn’t been updated in a couple of years. That doesn’t mean it won’t work, but if Google changes something, it could be a dead end.

01:19 You get Yagmail using pip install. Don’t forget the square bracket [all] modifier to make sure you get all parts of the package.

01:28 If you’re using Proton as your provider, you can use the Proton Mail Bridge instead. This allows you to connect through Python code, and it has its own Python package to help you do that.

01:41 Everything I’ve shown you so far is intended for sending mail to a small number of people, the same way you might in an email client. If you’re doing something larger, like a newsletter, you should be using a different kind of server.

01:54 Transaction email servers are meant for mass mailing. They send in batches and handle retries and that kind of good stuff. They also work very hard to make sure that places like Google and Microsoft continue to receive email from their domain, which makes it less likely for your newsletter to end up in the spam folder than if you did this yourself. There are lots of transactional commercial providers out there, including Brevo, Mailgun, Mailjet, Mailchimp, SendGrid, Amazon SES, and the list goes on.

02:24 Most of the providers have their own Python libraries, and some of them have free plans that limit the maximum number of messages you send per day or month, and some limit how many recipients you can define.

02:35 But if you’re experimenting to try to figure out which provider to choose, this allows you to at least test your code out. That’s it for the course. Next up, I’ll summarize the lessons and point you at other places you can learn more.

Become a Member to join the conversation.