How to Send Emails Using Python - Plain Text, Adding Attachments, HTML Emails, and More

How to Send Emails Using Python - Plain Text, Adding Attachments, HTML Emails, and More

Corey Schafer

5 лет назад

457,929 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Akshay Tony
Akshay Tony - 08.09.2023 20:02

Can you show how to reply to a mail

Ответить
Azizi Ally
Azizi Ally - 23.06.2023 11:33

Awesome

Ответить
Shubham Hire
Shubham Hire - 01.06.2023 13:56

This was such an amazing video, it took me a lot of time to pause and then understand and then apply it to the code, but it just made me learn so much , you are such an amazing teacher sir, thanks for sharing your knowledge with us.🙏🙏🙏

Ответить
James Lee1
James Lee1 - 24.05.2023 00:14

If at your work, you've developed a python web scrapping, and you want to setup an email alert/notification if the web scrapping program fails. How you develop an email alert/notification?

Ответить
jefferson jefferson
jefferson jefferson - 04.05.2023 01:41

hi corey, please is this method still working, i tried with python 2.7 the method did not work any update please, thanks

Ответить
Gilberto NM
Gilberto NM - 26.04.2023 06:57

Thank Youuu

Ответить
Retloe
Retloe - 05.04.2023 15:43

does it work for anyone else?

Ответить
TP
TP - 31.03.2023 14:49

i sent a pdf through the method in the video but i am unable to open that pdf, its says failed to load pdf. Does anyone have a solution for it?

Ответить
Maanas.P
Maanas.P - 18.03.2023 11:09

i tried this with outlook but it just sent a blank mail. Any reasons?

Ответить
Dontai Lewis
Dontai Lewis - 06.03.2023 23:50

Is there a way to hide the recipients form other recipients when sending?

Ответить
Chinmaya Pradhan
Chinmaya Pradhan - 28.02.2023 09:29

sir i need to send an external html attachment

Ответить
Jan Kowalski
Jan Kowalski - 11.02.2023 22:06

Email py has get_email_address_list which accepts both str and list. If the string has list of e-mails separated by , or ; it splits it to list.

Ответить
Алексей Соков
Алексей Соков - 04.01.2023 14:34

2023

Ответить
Anil Yadav
Anil Yadav - 30.12.2022 05:12

Hello Corey, Thank you very much for this video. It's extremely clear, fast pace, super useful. BR, Anil

Ответить
Novic Cen
Novic Cen - 29.11.2022 14:48

Beside the gmail thing,
do all the scripts still work nowadays -if we use an Smtp server?

Ответить
Slick Willie
Slick Willie - 21.11.2022 05:03

Using Windows 10, and the HTML color didn't pass through to the recipient. Otherwise fine. I suspect it's a Windows issue.

Ответить
Michael Cheng
Michael Cheng - 17.11.2022 22:26

this doesn't work anymore; google removed the settings.

Ответить
Jodi
Jodi - 08.11.2022 19:30

This tutorial was so simple and straightforward. Super helpful. AND it worked!! Thanks, will be sure to check out your other videos.

Ответить
J.Thomas Saldias
J.Thomas Saldias - 06.11.2022 04:37

Corey, i have some problems running the code if I write it as shown, but when copied to my VS it does ran great. Thank you for this great tutorial.

Ответить
Ace van Cleef
Ace van Cleef - 31.10.2022 00:57

Thank you, this clarified some questions.

Ответить
Paul Moss
Paul Moss - 30.10.2022 15:03

I have just found this video but it looks like lesssecureapps is no longer available from Google. Can I still use Python to send Gmail emails?

Ответить
Iriscomp
Iriscomp - 30.10.2022 10:28

Thanks a lot, It is just splendid explanation.

Ответить
Valerie Jackson
Valerie Jackson - 27.10.2022 01:46

Hi! How can I call the last excel file of a folder? the most recent that i already generated by python? ---> attach_file_name = '/i-want-only-the-last-excel-from-the-folder.xlsx'
attach_file = open(attach_file_name, 'rb')? any clue?

Ответить
Jorge Escobar
Jorge Escobar - 20.10.2022 18:55

I loved this one, it seems so simple to send emails here.

Ответить
mihai python
mihai python - 16.10.2022 13:09

why my message goes to spam folder, and how to fix it ?

Ответить
artur le perokè
artur le perokè - 14.10.2022 15:28

when using gmail: no longer supported as of May 30th, 2022

Ответить
THE SAD FACE
THE SAD FACE - 09.10.2022 19:43

Is there a way we can add python script between like html? For eg like we have a whole text and we have to change some two values inside the html ? Is it possible

Ответить
Kamal Dhungana
Kamal Dhungana - 20.09.2022 21:58

you explained things very nicely!

Ответить
AjairaHouse
AjairaHouse - 20.09.2022 10:41

Bro! how you set the email as important email?(priority)

Ответить
Alex Williams
Alex Williams - 14.09.2022 05:55

@Corey Schafer
Thanx for posting such a comprehensive vid. None of the other videos on email via Python touched on Google settings regarding 2-step or TLS.

Ответить
Fabio Fugiyama
Fabio Fugiyama - 11.09.2022 07:17

AMAZING

Ответить
Jordan Cachiaras
Jordan Cachiaras - 02.09.2022 14:37

On our RHEOS systems I am able to use /usr/sbin/sendmail or /bin/mailx to send simple plain text emails or even attachments. I am not logging in to a remote server ( that i know of ) to make this happen and yet I can send these messages. How can I access that same "pathway" using python and smtplib? I was able to send the emails as instructed using the 'localhost' but have not been able to send to other recipients. These machines are company machines and so I do not want to create an account with gmail or outlook to do this if possible.

Ответить
Milind Khobragade
Milind Khobragade - 02.09.2022 11:30

Thanks for the tut, as always it's very informative and explanatory.
You covered all but html content is visible in the mail and not the plain text which you set by msg.set_content("This is a plain text email") in the line 16. Would you please explain, I'm stuck at that point since 2 days.

Ответить
528 Madhu
528 Madhu - 27.08.2022 16:17

Outdated for 2022, smtp is not allowed as secure access in google...

Ответить
Escape Felicity
Escape Felicity - 20.08.2022 06:10

It might be a REAL GOOD IDEA to post the code
So we don't need to pry it out of that github mess.

Ответить
Dukeyys
Dukeyys - 04.08.2022 03:21

Hey, man is it possible to send outlook emails using smtp?

Ответить
Sena hugtfl
Sena hugtfl - 02.08.2022 00:32

hi ı have a issue when ı was writing my file path .According to the internet i ve written correct but for ATOM accepted if I only write full absolute path starting ffrom "C:".And it is so unfit could you hepl me ?

Ответить
xlikesasuke
xlikesasuke - 23.07.2022 23:09

Hey great video. Is there any way to attach a mp4 file?

Ответить
Dave
Dave - 21.07.2022 17:57

You can no longer use this method from gmail

Ответить
Mrc Rblr
Mrc Rblr - 15.07.2022 20:39

thank you for this amazing video

Ответить
XxDrexX
XxDrexX - 12.07.2022 07:56

Does all the email I send to has to have an app password? Because it ain't working!
It only works for the email I use to send with!

Ответить
John Carr
John Carr - 07.07.2022 18:02

FROM GOOGLE: To help keep your account secure, from May 30, 2022, ​​Google no longer supports the use of third-party Fapps or devices which ask you to sign in to your Google Account using only your username and password.

Important: This deadline does not apply to Google Workspace or Google Cloud Identity customers. The enforcement date for these customers will be announced on the Workspace blog at a later date.

Ответить
Krishna Rachh
Krishna Rachh - 07.07.2022 06:05

Hey Corey!
Recently google has blocked all 3rd party access and this method has started showing errror..
Do you suggest any other ways of sending email from python?
Thanks!

Ответить
Jithesh Kuyyalil
Jithesh Kuyyalil - 03.07.2022 22:43

works like a charm, thank you

Ответить
DarkLord
DarkLord - 03.07.2022 08:54

This is sooo amazing and helpful thank you so much ❤️✨

Ответить
A. Wessel
A. Wessel - 28.06.2022 05:30

Great video, Corey! I am a total newbie to Python, and you made this so easy to follow. Could you possibly create a video or point me towards a resource where a Python script is used to send an HTML email with variable data from a SQL query? For example, if I wanted to email a simple summary report with the sum of deposit balances, deposit counts, loan balances, and loan counts with HTML formatting, could this be done with a Python script?

Ответить
BNJ TAMIZHA
BNJ TAMIZHA - 21.06.2022 03:48

how o genarate emails with fixed date automaticly

Ответить
Amit ozolve
Amit ozolve - 17.06.2022 06:54

Great video... just want to know is it possible to send email to 100 or more people in same time?

Ответить