If you get hundreds of test email in your inbox, don't get disturbed! Be happy to know that hundreds of people implemented what they learned here... :) As always, Corey, you are one of the best in teaching python. Thanks for this contribution.
hey man Where am I wrong ?? my code = = = import os import smtplib from email.message import EmailMessage EMAIL_ADDRESS = os.environ.get('EMAIL_USER') EMAIL_PASSWORD = os.environ.get('EMAIL_PASS') msg = EmailMessage() msg['subject'] = 'teste de email' msg['from'] = 'anymail@gmail.com' msg['to'] = 'anymail@gmail.com' msg.set_content('teste de emial enviado pelo script em python') with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp: smtp.login(EMAIL_ADDRESS,EMAIL_PASSWORD) smtp.send_message(msg)
@@cicerosilva-ye8mn what IDE are you using? im using pycharm and i had to go into the interpreter settings to add the module. search up "how to add module to pycharm"
For anyone that had trouble, I changed my port number from 587 to 25 and it fixed the 'gaierror' for me. Also huge thanks to you Corey!! Awesome, streamlined content.
Your videos are my lifeline!! I am a retired programmer trying to learn Python. I've not used any other language apart from FoxPro since using Pascal 30 years ago.
*Question on HTML email:* *[SOVED]* Is there a way to send a HTML email without having to write it manually in triple quote, but more automated? Like if I had a file called "email.html", and I didn't want to send it as an attachment, but the email itself. Thanks, anyone. EDIT: I found a solution! If anyone is interested here it is; ### with open('my_HTML_file.html', 'rb') as f: file_data = f.read() file_type = imghdr.what(f.name) file_name = f.name #print(file_data) file_string = file_data.decode(encoding='UTF-8') #print("
Where does this code comes in the code. I’ve been having alternative error when I tried sending the HTML link on the code. Please some help to get me through
This is excellent tutorial, but you can please tell what should be used for maintype and subtype for other kinds of attachment such as csv, excel etc. And how this process stated in video is different from MIME which is present all over internet for sending attachment ? I am quite confused regarding MIME
All your videos are "GOLD MINE" on the internet. I've learnt better with your videos than most others i've tried, I feel i owe you a lot , I'm making patreon contribution now!! Thanks a lott !!! god bless you Corey!!
Corey can you do videos about problem solving? Data structures and algorithms and when to use them Didn't watch the video yet but I know it would be good xD
Oh man this video probably saved me hours of unnecessary struggle. If you could somehow get a link to this video as one of the top answers to google queries like "Python send email with attachment pdf" I bet you would get some extra traffic! Thank you so much for your work! I know that my learning process will be much smoother when I find one of your videos on the topic I want to learn. Youda best
As always, another great video chuck full of practical tips. I have never seen a video that you made that I felt was useless or poorly made. Your videos are always top notch and the best.
Thanks, Corey. That worked great. Note that now you need to set up a App Password if you're using a Google account. This is to get around the 2-step verification process.
@@venkataramanansundaresan321 yes but where? Where exactly are stuck? You gotta create a mailing function where you pass in the mail address and it sends a mail everytime someone hits subscribe button on the website with their mail ID filled in from the input box
you are genius..........thank a lot of about what you doing with your lightfully teaching..... you are one of the best teacher in this world...god bless you and your family too....................you are a light for our brains
Doesn't work. I either get SMTPResponseException: (334, b'UGFzc3dvcmQ6'), or SMTPAuthenticationError: (535, b'Authentication credentials invalid'). Checked everything multiple times, and tried different variations.
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?
The Tutorial was very useful , it taught lot of stuff ,great work👍🏻 If anyone is getting Error for Environment Variable then just try by installing:- pip3 install python-dotenv then create '.env' file as it is mention your variable in that eg:- EMAIL_USER=abc@gmail.com EMAIL_PASS=abc@123 and python path lib USER=os.getenv('EMAIL_USER') PASS=os.getenv('EMAIL_PASS') just like that it's Done check by using print(USER,"",PASS).🤘🏻
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.🙏🙏🙏
Thanks so much Corey! It's such a nice feeling to get all the code working and follow along. I really appreciate the list of contacts idea at the end, it seems so logical to do it that way and what can I say, I'm a big fan of logic! :) Thanks again! I'm loving your content and explanations.
Corey, can you post some of useful website such as documentations that are related to this video? Your video is really helpful but after that when I try other variations or face some problems, I am not able to do go through the problems. It would be really helpful where you have watched resource/documents for the video. You are the best!
@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.
Could you make some toturial for creation of document like in word /pdf with specific elements(fields) that must be taken from mutliple(also online) sources? Amazing toturial sir!!
Excellent video Corey! The steps were very clearly explained and worked without any issues. One question - the example that you provide is for including multiple attachments to a single email; however, if I wish to include the list of attachments to individual emails (one attachment per email), what would be the best way to proceed? I have looked this up in details and not found a satisfactory solution. Will greatly appreciate your help with this.
I just bumped into your video. It is amazing. Thank you so much. I am so very new to Python and I think that this is one of the best tutorial I ahbe ever seen here on youtube. Thank you so much.
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.
Can you do a video on Python and Docker enabled applications, please? BTW this video was very informative and learned new stuff, another ace up my sleeve when needed for my project.
Thanks a lot mate, I appreciate the effort you have put into making this video so easy to understand while also meeting the target of the intended title of the video. After looking online for a long time I finally came across your tutorial and I'm leaving with more information than I needed which is all so useful. So once again thanks a lot cus you made my day and all the best for the growth of your channel :))))
beginner's question: I generated a password protected app named "Python test" in my Gmail settings and wrote the program in Py-charm IDE script. But I did not receive any email as you did? can you tell me what am I doing wrong there?
I had been using smtplib.SMTP with the ehlo and starttls for awhile. Nice to know there is a more elegant way to do the same thing with smtp.SMTP_SSL. Thanks for the video!
I always get this error when I use your code with Outlook SMTP hostname and Port raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b'5.7.8 Error: authentication failed: authentication failure')
on 17:01 minute that way Im trying to connect to host but it gives me error using 465 port raise SMTPServerDisconnected("Connection unexpectedly closed") smtplib.SMTPServerDisconnected: Connection unexpectedly closed
Hi Corey, I watch your TH-cam content via Python. Thank you so much for your contribution to Opensource. I'm working on a project and was wondering if we could Zoom sometime this week? Thank you for your time and I look forward to hearing from you soon. Best,
Hey Aksana. What time of project are you working on? If you could email me then I probably have a better chance of seeing your response, but I can’t promise anything because I get a lot of messages each day
Thanks Corey, your videos has helped Me alot as a self taught programmer, will be exciting to see you do videos on Blockchain, Maybe Stellar Blockchain. Thanks Soooooo much
Great tutorial. I follow along and step by step, it works perfectly. But my question is, how we receive & read email with Python? Thanking you in advance 😊😊
If you get hundreds of test email in your inbox, don't get disturbed! Be happy to know that hundreds of people implemented what they learned here... :) As always, Corey, you are one of the best in teaching python. Thanks for this contribution.
hey man Where am I wrong ?? my code = = = import os
import smtplib
from email.message import EmailMessage
EMAIL_ADDRESS = os.environ.get('EMAIL_USER')
EMAIL_PASSWORD = os.environ.get('EMAIL_PASS')
msg = EmailMessage()
msg['subject'] = 'teste de email'
msg['from'] = 'anymail@gmail.com'
msg['to'] = 'anymail@gmail.com'
msg.set_content('teste de emial enviado pelo script em python')
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(EMAIL_ADDRESS,EMAIL_PASSWORD)
smtp.send_message(msg)
@@cicerosilva-ye8mn what error? and what line is the error on?
@@motherfuqjohnson5460 in the sccrip ModuleNotFoundError: No module named 'email.message'; 'email' is not a package
at this from email.message import EmailMessage
@@cicerosilva-ye8mn what IDE are you using? im using pycharm and i had to go into the interpreter settings to add the module. search up "how to add module to pycharm"
Thank you, for putting out a video of something so useful that many Pythonistas ask.
Pythonistas
For anyone that had trouble, I changed my port number from 587 to 25 and it fixed the 'gaierror' for me. Also huge thanks to you Corey!! Awesome, streamlined content.
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options.
check out here:
al-taie.github.io/quick-mailer
Your videos are my lifeline!! I am a retired programmer trying to learn Python. I've not used any other language apart from FoxPro since using Pascal 30 years ago.
*Question on HTML email:* *[SOVED]*
Is there a way to send a HTML email without having to write it manually in triple quote, but more automated?
Like if I had a file called "email.html", and I didn't want to send it as an attachment, but the email itself.
Thanks, anyone.
EDIT: I found a solution! If anyone is interested here it is;
###
with open('my_HTML_file.html', 'rb') as f:
file_data = f.read()
file_type = imghdr.what(f.name)
file_name = f.name
#print(file_data)
file_string = file_data.decode(encoding='UTF-8')
#print("
::: The file decoded into a string :::
", file_string)
msg.add_alternative(file_string, subtype='html')
###
Where does this code comes in the code. I’ve been having alternative error when I tried sending the HTML link on the code. Please some help to get me through
Hey, Thanks man !! I was just searching for the same. I have an external html file read into the script. That was semantic
This is excellent tutorial, but you can please tell what should be used for maintype and subtype for other kinds of attachment such as csv, excel etc. And how this process stated in video is different from MIME which is present all over internet for sending attachment ? I am quite confused regarding MIME
All your videos are "GOLD MINE" on the internet. I've learnt better with your videos than most others i've tried, I feel i owe you a lot , I'm making patreon contribution now!! Thanks a lott !!! god bless you Corey!!
If this worked for you can you help me I hate to bother you
I can watch your videos on a tablet without getting blind... I'm going to thumbs up all your videos!
Corey can you do videos about problem solving?
Data structures and algorithms and when to use them
Didn't watch the video yet but I know it would be good xD
I agree with this post. Data structures and algorithms would be a very good fundamental for a developer(beginner or intermediate).
Time complexity problems
Yes! You are great teacher, we would love to see your DSA lessons!
thank you. you explained everything perfectly line by line and argument by argument
Oh man this video probably saved me hours of unnecessary struggle. If you could somehow get a link to this video as one of the top answers to google queries like "Python send email with attachment pdf" I bet you would get some extra traffic!
Thank you so much for your work! I know that my learning process will be much smoother when I find one of your videos on the topic I want to learn. Youda best
your channel is a gem mine :)
As always, another great video chuck full of practical tips. I have never seen a video that you made that I felt was useless or poorly made. Your videos are always top notch and the best.
Thanks, Corey. That worked great. Note that now you need to set up a App Password if you're using a Google account. This is to get around the 2-step verification process.
I implemented it my flask back-end for sending automated mails to those who subscribe 😎. Thanks a lot Corey for this fantastic video.
can you send the code for it i am also trying to do the same but dont know how to do
@@venkataramanansundaresan321 yes but where? Where exactly are stuck? You gotta create a mailing function where you pass in the mail address and it sends a mail everytime someone hits subscribe button on the website with their mail ID filled in from the input box
you are genius..........thank a lot of about what you doing with your lightfully teaching..... you are one of the best teacher in this world...god bless you and your family too....................you are a light for our brains
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options.
check out here:
al-taie.github.io/quick-mailer
What I like about this is, eventhough the code is solid it didnt work untill I understood what I was doing. Thanks for that. That is a valuable lesson
Doesn't work. I either get SMTPResponseException: (334, b'UGFzc3dvcmQ6'), or SMTPAuthenticationError: (535, b'Authentication credentials invalid'). Checked everything multiple times, and tried different variations.
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?
The Tutorial was very useful , it taught lot of stuff ,great work👍🏻
If anyone is getting Error for Environment Variable then just try by installing:-
pip3 install python-dotenv
then create '.env' file as it is mention your variable in that eg:- EMAIL_USER=abc@gmail.com EMAIL_PASS=abc@123 and
python
path lib
USER=os.getenv('EMAIL_USER')
PASS=os.getenv('EMAIL_PASS')
just like that it's Done check by using print(USER,"",PASS).🤘🏻
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.🙏🙏🙏
This tutorial was so simple and straightforward. Super helpful. AND it worked!! Thanks, will be sure to check out your other videos.
Bro this feature was turned off by google couple of months ago how you say that it worked?
Only youtuber I can trust with python content!
Thanks so much Corey! It's such a nice feeling to get all the code working and follow along. I really appreciate the list of contacts idea at the end, it seems so logical to do it that way and what can I say, I'm a big fan of logic! :)
Thanks again! I'm loving your content and explanations.
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options.
al-taie.github.io/quick-mailer
Corey, can you post some of useful website such as documentations that are related to this video?
Your video is really helpful but after that when I try other variations or face some problems, I am not able to do go through the problems.
It would be really helpful where you have watched resource/documents for the video. You are the best!
Multithreading in python --- please cover this
@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.
Thanks a lot helped me generate automatic email notifications in my web scraping project !!
PS- Puppy is so cute :D
Nice Video! KIndly make a video on "Sending Whatsapp messages" using Python
lol.. then its a disaster
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.
Thank you Corey for the video. It will be really nice if you can make a video about how to read emails from Gmail
this is really awesome and helpful. you simplify it so much. thank you!!
Could you make some toturial for creation of document like in word /pdf with specific elements(fields) that must be taken from mutliple(also online) sources? Amazing toturial sir!!
Excellent video Corey! The steps were very clearly explained and worked without any issues. One question - the example that you provide is for including multiple attachments to a single email; however, if I wish to include the list of attachments to individual emails (one attachment per email), what would be the best way to proceed? I have looked this up in details and not found a satisfactory solution. Will greatly appreciate your help with this.
Your python tutorials are unfailingly amazing!
I just bumped into your video. It is amazing. Thank you so much. I am so very new to Python and I think that this is one of the best tutorial I ahbe ever seen here on youtube. Thank you so much.
Thank you very much Corey. What could be the reason for someone to dislike such a valuable video?😂
I loved this one, it seems so simple to send emails here.
Hey Corey, you are real tech nerd. Video is awesome.
Thanks for explaining each type in detail
when I search: myaccount.google.com/apppasswords
it gives me an error that says: The setting you are looking for is not available for your account.
Thank you Corey for another great video. Hope to see you back again in the future.
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.
Can you do a video on Python and Docker enabled applications, please? BTW this video was very informative and learned new stuff, another ace up my sleeve when needed for my project.
Great video, thank you for the tutorial. Very thorough!
One question: How can the html string email have logos that are created as PNGs or JPEGs?
You can use (quick-mailer) module, to send email in two lines of code.
al-taie.github.io/quick-mailer
Thanks a lot, especially for the HTML part, it was the only thing it worked for me after trying a lot of different options
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options.
check out here:
al-taie.github.io/quick-mailer
We need more people like you man!.
Thanks a lot mate, I appreciate the effort you have put into making this video so easy to understand while also meeting the target of the intended title of the video. After looking online for a long time I finally came across your tutorial and I'm leaving with more information than I needed which is all so useful. So once again thanks a lot cus you made my day and all the best for the growth of your channel :))))
do you know where in the code should i put by enviroment variable of the app password i
Thanks buddy
you saved my project, I really appreciate your work.
like many of your videos, you got the best content and also every methods works :) thanks a lot mate!
Bronx puppy 🐶 is cute 😂
Thank you, this clarified some questions.
Thumbs up. Love all your vids, they are always so informative and useful.
Thanks! This video made de subject more clear to me and I could follow the ressults
beginner's question:
I generated a password protected app named "Python test" in my Gmail settings and wrote the program in Py-charm IDE script. But I did not receive any email as you did? can you tell me what am I doing wrong there?
YOU ARE THE GOAT COREY
I had been using smtplib.SMTP with the ehlo and starttls for awhile. Nice to know there is a more elegant way to do the same thing with smtp.SMTP_SSL. Thanks for the video!
where do i put the app password in the code?
Awesome tutorial!!!
This video just gave a idea for a new project
Building a Custom Mailing Enterprise Software now.
Thanks a lot!!
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options.
al-taie.github.io/quick-mailer
@@al-taie thanks 👍
Hope these aren't a duplicate questions: How do you send to multiple recipients? Plus is there a site or book where all this is documented?
To send to multiple people you will use an array, or list then use a for loop to send each of the emails..
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options
check out here:
al-taie.github.io/quick-mailer
Very intuitive !
Corey, thank you very much for this video. It's extremely clear, fast pace, super useful. Thanks mate!
Hello Corey, Thank you very much for this video. It's extremely clear, fast pace, super useful. BR, Anil
Thanks a lot, It is just splendid explanation.
this was so amazing!!!
loved all your videos. big fan
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options
check out here:
al-taie.github.io/quick-mailer
I always get this error when I use your code with Outlook SMTP hostname and Port
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Error: authentication failed: authentication failure')
I am getting the same error. By Any chance , did you get the a solution to send email via outlook.com
U might need to disable MFA first.
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options.
al-taie.github.io/quick-mailer
Thanks for the video. Its was very helpful
Thanks for the amazing video ☺️
You are a Python God.
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options.
check out here:
al-taie.github.io/quick-mailer
Very well. Thanks for Sharing.
How come it tells me The setting you are looking for is not available for your account.
when I try to go to app passwords? :(
You need two factor authentication turned on
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options.
al-taie.github.io/quick-mailer
How to I add a variable in the html code for the gmail?
looks like they removed smtpd in python 3.12, couldn't test on localhost. Great video. God bless..
you explained things very nicely!
Protect Coray at all cost, he is a legend
Very clear and simple.
on 17:01 minute that way Im trying to connect to host but it gives me error using 465 port
raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
17:25 adding attachments explination starts
Super useful! Thank you.
Loving your work! Thank you!
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options
check out here:
al-taie.github.io/quick-mailer
Can you make a video on replying e-mails maintaining the history?
You seriously are a genius!
Love all you videos!
Can we read incoming emails in a similar way? Is there a possibility to do that?
Thank you so much this video is realy helpfull
Got a new subscriber because of the content of this video!
Thank you sir, it helped me understand sending email in a simple way
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options.
al-taie.github.io/quick-mailer
Thanks
Hi Corey,
I watch your TH-cam content via Python. Thank you so much for your contribution to Opensource.
I'm working on a project and was wondering if we could Zoom sometime this week?
Thank you for your time and I look forward to hearing from you soon.
Best,
Hey Aksana. What time of project are you working on? If you could email me then I probably have a better chance of seeing your response, but I can’t promise anything because I get a lot of messages each day
Great video! It would be interesting to see how email clients protect against mass email spam haha.
watching coreys videos is like getting stack overflow on steroids
Amazing channel, subscribing right away
Beside the gmail thing,
do all the scripts still work nowadays -if we use an Smtp server?
Another wonderful video!
You can use (quick-mailer) module, to send email in two lines of code, with a lot of options.
check out here:
al-taie.github.io/quick-mailer
Thanks for your work!
Thank u so much, Corey! Greetings from Mexico!
Excellent! Thanks
Great video. Just one question: was your email box bombed by test emails from the viewers in the end?
Thanks Corey, your videos has helped Me alot as a self taught programmer, will be exciting to see you do videos on Blockchain, Maybe Stellar Blockchain.
Thanks Soooooo much
thanks. the video is pretty extensive.
Great tutorial. I follow along and step by step, it works perfectly. But my question is, how we receive & read email with Python? Thanking you in advance 😊😊
I might try to throw a video together on that subject in the near future
@@coreyms thank you sir.
This was really helpful. Thank you very much!
It works! Thank you.