How to Send Emails with Python [New Method 2023]

Поділитися
Вставка
  • Опубліковано 30 вер 2024

КОМЕНТАРІ • 353

  • @ThePyCoach
    @ThePyCoach  Рік тому +10

    For those asking. Here's how you can add attachments and send emails to multiple receivers: ua-cam.com/video/ANCKLzvvO5A/v-deo.html

  • @EngineerFormidable
    @EngineerFormidable 2 роки тому +86

    Works perfectly, thank you. Literally spent 3 days looking for something as simple as this. Thanks a lot !

  • @labscience8271
    @labscience8271 2 роки тому +14

    Thank you! I sent my first automated mail, and I have some plans to do with it. Very good explanation!

  • @thisoldfox
    @thisoldfox 2 роки тому +13

    I too spent many days trying to create emails with Python and this video showed me how. Thanks for the great video.

  • @RodrygoDeSilva
    @RodrygoDeSilva 2 роки тому +2

    Thank you so much bro but I have one question. I am getting a exited with code=1. I'm sure that means that there's one line of code that's wrong but I rechecked everything with your video and it matches yet I'm getting an error. Any advice you can give me? thanks.

  • @deekshantwadhwa
    @deekshantwadhwa 2 роки тому +20

    Great work man, an IT company that my Dad uses in his office was asking for $5000 for this upgrade in the software they created for his office. After searching for the reason why the emails had stopped working from their software, what changes has Google brought forward and the fix (your video), I had a "chat" with them, and guess what, new budget = $100 which is still too much, but their mails are now working back again through their software. #KnowledgeIsPower

    • @larsenmathias4499
      @larsenmathias4499 4 місяці тому

      Why dont you guys use services like msg91 its much better

    • @mfxtrading7027
      @mfxtrading7027 4 місяці тому

      if the dev is in India - okay, otherwise you're just a cheap guy who should learn how to code

    • @TechySatvik
      @TechySatvik 4 місяці тому

      wow

  • @Raizun
    @Raizun 6 місяців тому +2

    Thank you a lot! The best guide. Easy to write and it actually works!

  • @chestadhingra2611
    @chestadhingra2611 Рік тому +1

    The video is very informative, but while following along I am getting the error "Application-specific password require". Though I have generated the app password in the gmail and 2-step verfication is also on. Could anyone help? Thanks in advance

  • @southvillechris
    @southvillechris 10 місяців тому +3

    Fantastic video - thank you so much! I've been banging my head against a wall trying to send smtp messages - and this one actually worked!

  • @rincondepython
    @rincondepython Рік тому +1

    updating 2023: it's still working!

  • @HomiePlaysYT
    @HomiePlaysYT Рік тому +1

    This video saved my ass, I was so frustated when a project which I made about 2 years ago broke. First it took me time to realize why it was breaking then I saw that google changed its policy. Anyways thnx.

    • @ThePyCoach
      @ThePyCoach  Рік тому

      You're welcome. Just today I uploaded a new video about this. The method is still working. I just added more things like how to add attachments and send emails to multiple receivers!

  • @richardbrakoh4154
    @richardbrakoh4154 2 роки тому +2

    I did the code the same on my house windows laptop and it works fine. However when I coded on my MacBook Pro, there was an error which says “No module named email.message; email is not a package “. Why is that?

  • @d3f3kt57
    @d3f3kt57 Рік тому +2

    Worked perfectly. I wasted 4 hours yesterday trying to get this to work with a much more complicated method involving setting up an SMTP server on localhost, which did not work.

  • @sakethkumarpeddi2089
    @sakethkumarpeddi2089 Місяць тому +1

    Man. You are just awesome. I've spent almost half of my day on how to send emails with free SMTP services. Thank you, Thank you so much. 😊

  • @revanthreddy9781
    @revanthreddy9781 2 роки тому +2

    For email.message which package is necessary to install?...

  • @ShaikhAsif-u7r
    @ShaikhAsif-u7r 10 місяців тому +1

    Thanks for this video

  • @wintermorillo6567
    @wintermorillo6567 Рік тому +4

    I spent almost a month trying to find a solution for this, and in less than 10 minutes I found the solution. Thank you for this tutorial.

  • @siarnt3566
    @siarnt3566 2 роки тому +5

    You are the GOAT for this video. I had a site that was running for so long sending emails with the "allow third party" setting on Gmail. Ever since they removed that feature I couldn't get it to work and all the other tutorials on UA-cam were made before this was the case.
    Thank you so much for releasing this video promptly. I will definitely be checking out some more videos in the future!!

    • @ThePyCoach
      @ThePyCoach  2 роки тому +2

      Yeah I know. That gave me extra motivation to make this video. Good timing!

    • @wcsdiaries
      @wcsdiaries 2 роки тому

      @@ThePyCoach What do you do if it sends the email, but it just goes straight to junk mail? Does it matter which phone/browser you use? I noticed with iphone just sent email straight to junk, but android didn't

    • @-potato-god-2311
      @-potato-god-2311 Рік тому

      @@wcsdiaries I'm guessing your iPhone has some option enables which sends automated messages into junk. I'm not too sure about it.

  • @jnrahm2038
    @jnrahm2038 Рік тому +2

    Took me so many failed attempts until I found your video. Worked first time, Thanks!!

  • @grigorijdudnik575
    @grigorijdudnik575 8 місяців тому +1

    Hey Frank, thanks for clear tutorial, It helped me to finally did that. I have little remark for it: as you hidden your app password, it was not obvious if words in password should be separated by spaces, or written in common, or even separated other way (after test I have response: spaces are ok). I suggest to make it more explicit, maybe next time to use some password which you'll delete before publishing the video.

  • @francislau9292
    @francislau9292 17 днів тому

    I have problem creaite a app passwords - there was an error generating an app password.
    I have tried below methods:
    1) signing out all others google account while creating app password
    2) Using a different IP while attempting creating app password.
    Yet I still have this error message popping up. Do you have any recommendation please?

  • @DefaultAdamYT
    @DefaultAdamYT Рік тому +1

    great video

  • @marronnier17
    @marronnier17 Місяць тому

    Thank you so much. You made a complicated ( for me) topic very straight forward. It worked first time. Of course Google has changed some of it's gmail setting screens and menu but otherwise perfect. Thanks again.

  • @geirha75
    @geirha75 11 місяців тому

    advice: when used with crontab, the py script fails. The password variable will not work with crontab. The script works ok when run manually.

  • @Schollii68
    @Schollii68 11 місяців тому

    Nice video, thanks! However, that apppasswords url does not work for me. It's odd that you edit the URL like that, instead of going via the google account page: Security -> 2 step verification -> scroll to bottom -> you will see App Passwords. Click, when you get there I get essentially the same as you, but I can't select a specific app and language, i can only create a generic app password.

  • @another-niko-pfp-holder
    @another-niko-pfp-holder 2 місяці тому

    What if I want to write the script for myself and never share it, should I also save the password as an env variable?
    (also thanks for the tutorial, exim don't want to work so this is very useful for me)

  • @siirdenkalbe
    @siirdenkalbe Рік тому

    I did exactly you did but ı had this error: ConnectionResetError: [WinError 10054]
    Can you help me bro? or anyone?

  • @brucenelm
    @brucenelm 5 місяців тому

    Thanks for sharing the video! I'm curious, do you think there's a risk of the emails getting flagged as spam?

  • @msm_akbar
    @msm_akbar 2 роки тому +3

    Thank you so much, Frank.
    My first Automated email was a success.

  • @SigmoidNOTIFY
    @SigmoidNOTIFY Рік тому +1

    My god it worked! Thank you so much i was not expecting it to work that simple!

  • @waynearul2003
    @waynearul2003 2 роки тому +5

    ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:997)

  • @wmesquita7723
    @wmesquita7723 4 місяці тому

    Hi Pycoach. I had some dificults to set the security from gmail but he process happend with sucess! Ths for the video!

  • @Stay_Positive_live
    @Stay_Positive_live Рік тому +1

    you're a genius

  • @vuinhduy8314
    @vuinhduy8314 4 місяці тому

    Dear Sir,
    I'm appriciate your content. Help me alot to cut my work time.
    Best wish to you.

  • @Fabriciod_Crv
    @Fabriciod_Crv 8 місяців тому

    Im getting an “Application password required” error, even though the password for my email is set there

  • @miguelgarcia-vg1fh
    @miguelgarcia-vg1fh Рік тому

    Did not work for me. I get time out error: [win error 10060] a connection attempt failed because the connected party did not properly respond....
    Any tips?

  • @mannanjaffery
    @mannanjaffery Рік тому

    HI bro i am getting an error in my code and i tried everything please tell me how can I get rid of this error:TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.please tell me what is wrong with my code and how i can correct it?

  • @_jirkaa_5170
    @_jirkaa_5170 2 роки тому +1

    didnt work :/

  • @Alva1326
    @Alva1326 Рік тому

    How many mails can i send daily using this approach? i have a database of 100.000+ contacts, I wonder what is the best method to send all those emails.

  • @igorruiz2653
    @igorruiz2653 4 місяці тому

    Nice video! it works me perfectly. Thanks

  • @geirha75
    @geirha75 11 місяців тому

    how can I include text from a text file in the body message? The text file contains results of a script.

  • @brendanmchugh9542
    @brendanmchugh9542 Рік тому

    Does anyone know how to BCC people using this? I don't want the people I'm emailing seeing that I'm emailing other people

  • @mrgabriel6295
    @mrgabriel6295 Рік тому +1

    Works perfectly but how about sending to bulk email, like having a list of emails in a txt/csv file and sending via python. I will appreciate your response. Thanks 💖💖💖

  • @cemgencal7386
    @cemgencal7386 Рік тому

    when i run the file i always got this error : No module named 'email.message'; 'email' is not a package
    I intall pip email but it still dont work, can someone help me please

  • @TechnoSpirit
    @TechnoSpirit 2 роки тому +2

    Bless the creator of this video! An infinity of thanks will not be enough!

  • @Levendo
    @Levendo 14 днів тому

    Thanks! Finally, a working solution!!

  • @paulmoss4199
    @paulmoss4199 10 місяців тому

    I am getting the error:
    File "C:\Program Files\Python311\Lib\smtplib.py", line 652, in auth
    authobject(challenge).encode('ascii'), eol='')
    AttributeError: 'NoneType' object has no attribute 'encode

  • @ramage7646
    @ramage7646 Рік тому

    I have a question... Is there a risk of your mail being sent to the spam folder?

  • @t7732155980
    @t7732155980 2 роки тому +4

    Thanks, A simple and accurate step by step explanation. Works perfectly.

  • @technicalaasaan633
    @technicalaasaan633 Рік тому +1

    thank you... I tried many way all are outdated one.

  • @ilaiosking3963
    @ilaiosking3963 Рік тому +1

    Thank you very much! Worked on the first time

  • @rafaelfonseca7942
    @rafaelfonseca7942 Рік тому +2

    Nice video. Worked flawlessly.
    Thanks for this great content!

  • @M1szS
    @M1szS Рік тому

    bro thanks so much for the this, i was so confused why it didnt work when i put my password in there, had no idea you have to make app specific passwords

  • @kabala369
    @kabala369 Рік тому

    Thank you very much, is there anyone trying this in Feb 2023?

  • @hadiqamehdi4663
    @hadiqamehdi4663 Рік тому

    i have an issue with from email.message line it pops up the error as email.message doesnot exist could you please help me

  • @saqibawan6483
    @saqibawan6483 9 місяців тому

    I tried this but my sended emails going into spam folder why is that?

  • @lorenzoscandolara4941
    @lorenzoscandolara4941 3 місяці тому

    You are the number 1, the best thanks a lot my friend

  • @MohammedKMM
    @MohammedKMM Рік тому

    I don't understand the part: define context=context. What is that for?

  • @linasg90
    @linasg90 Рік тому

    What if I need to schedule them to be sent every 6 months for example

  • @andreviniciusbezerradasilv9335

    how can i send that email to multiple receivers ? I can store the other receivers in a list or just write a string with all the emails ?

  • @umidjonsubxonqulov4941
    @umidjonsubxonqulov4941 2 роки тому +1

    thank you so much for the great video

  • @osman_gedik
    @osman_gedik 3 місяці тому

    Ich I want to send 10 emails at the same time, how do I do the loop here?

  • @blackscreenslppeingrain
    @blackscreenslppeingrain Рік тому

    can this method be used to send bulk email for marketing?

  • @inakimusic570
    @inakimusic570 Рік тому

    14/10/2022 is sucessfuly 👍thanks

  • @jithingeorge1946
    @jithingeorge1946 10 місяців тому

    when I run this it does not end. the program keeps going forever.

  • @MsNd4Spd
    @MsNd4Spd 2 роки тому +2

    After a whole week of trying out other methods, this one worked perfectly.

  • @yasserelhor8912
    @yasserelhor8912 Рік тому

    How i can send emails to too many people

  • @argjentzenuni9345
    @argjentzenuni9345 Рік тому

    if anyone is interested in Online Affiliate Marketing !!!!

  • @ashishjstar
    @ashishjstar 2 роки тому +1

    It's working dude!! Thanks a lot 😀

  • @pushpanshuasthana7589
    @pushpanshuasthana7589 Рік тому

    I get this error, what to do now?
    em['From'] = email_sender
    TypeError: 'type' object does not support item assignment

  • @thekiddoquiz
    @thekiddoquiz Рік тому +1

    Method working greatly👌

  • @alderiatefanclub1576
    @alderiatefanclub1576 Рік тому +3

    Thanks a lot ! Your video is crystal clear and helpful :)

  • @chezar3075
    @chezar3075 6 місяців тому

    Thank you very much, it helped a lot

  • @wunterschlee1457
    @wunterschlee1457 Рік тому

    Going to /passwords yields 401

  • @issamelimrany
    @issamelimrany 2 місяці тому

    Thank you ! still working as of now.

  • @Ravi.Kumar-
    @Ravi.Kumar- Рік тому

    can we use fake email in sender option. just wanted to test it.

  • @Mr.Aswin_Das
    @Mr.Aswin_Das Рік тому

    thank you so much buddy.. so helpful

  • @frida_m4426
    @frida_m4426 11 місяців тому

    I want to see how you created the os variable...

  • @prabhnoorsinghchowdhary7935
    @prabhnoorsinghchowdhary7935 2 роки тому +1

    Man I am so grateful Thanks a lot

  • @Blazey12-o8x
    @Blazey12-o8x 9 місяців тому

    SSL is not a good secuirty layer tls is better

  • @Truecrimecommunity
    @Truecrimecommunity Рік тому

    Don’t make fun of me, but how does this help anyone automate things? He had to manually type in the message and the receiver? Wouldn’t you have to do that every single time, or does this work in a way that you can tell python to get new emails from wherever the emails are stored by using variables and and have python set to automatically search for new emails etc? I am fairly decent to computers but I do not know how to write code myself. But is the idea behind this to be able to have applications you have built to be able to automate emails without using a 3rd party service like zapier? But wouldn’t the message you send to everyone all be the same message unless you manually typed out a new message each time? Is this basically for automating the same process over and over like welcome emails, or bulk email marketing where you create an email and then send that to all of your list and having python delay how fast they are sent and prevent you from going over your daily allowed emails sent? I got here because I was watching another video where they showed how to use python to send emails from many gmail accounts. It automatically keeps track of how many it’s sent for the day and it spreads it’s sending across many accounts and puts 60 seconds between each Bach of 50 emails sent and then shuts off each account once 500 emails has been sent with that account.
    Man the amount of money people who know how to code can make is insane. It allows you to have an army of free employees in the form of automation. I wish like hell I knew how to code.
    What would the average person who knows how to do this charge to build this for you to where it pulls e-mail addresses from a file and will automatically send your pre created email to any new email address added to that file, by having python do a check say every hour to see if there are any new emails to send to. I say this is because I would need things very basic to where when I kid new email addresses to the file the rest of the world is automatically done.
    Are we looking at a few hundreds dollars or what? I saw a comment where a guy said a company charged $100 to build this for his dads company and he said even that was too much. So I’m just curious if this is 10 mins if work for someone who knows how to code? I mean this guys video was 11 minutes, so if that’s all it would take to build this where do I go ? Fiver? I would want to use google sheets if possible, I assume that would work well since it would be gmail that’s sending. I know you are probably laughing but I don’t know how to use SQL etc. And I would like to be able to just copy and paste email addresses into the spreadsheet python is coded to check for new emails every hour. The email sent would be exactly the same. And I would use 6-7 gmail accounts.
    I would want python to warm up the email addresses though first for a week or two. And then have each account send approx 250 per day.
    The other video I watched also removed any email address from their file if it failed to send, which I didn’t realize that was possible. I didn’t is was possible to use python for email verification prior to sending.
    I know this is long and I am all over the place. I have ADHD And I am out of meds. Would greatly appreciate anyone who tries to answer my questions, and like a said. I know nothing of coding without the help of chat CPT.

  • @Amir-English
    @Amir-English 9 місяців тому

    Will you tell how to send an email to multiple people, pls

  • @nagendra9853
    @nagendra9853 Рік тому

    Thank You, but how to attach file to this email

  • @uscbruin213
    @uscbruin213 Рік тому +2

    Amazing! I was searching Google and stack overflow for this all day and then watched your video and it was simple!

    • @ThePyCoach
      @ThePyCoach  Рік тому +2

      A couple of months ago I was searching like you and after hours I read that Google had changed his security ... in that moment I understood why the old tutorials didn't work

  • @FernandoFischer6048
    @FernandoFischer6048 Рік тому

    Muchas gracias amigo me inscribo atu canal es oro puro !
    Saludos

  • @AmanPandey-bd1sj
    @AmanPandey-bd1sj 7 місяців тому

    Working thanks for the video 😊

  • @alwaysbg600
    @alwaysbg600 Рік тому

    python - Email serch phon number and phon number password
    video plz

  • @leelasri5885
    @leelasri5885 Рік тому

    what if the receiver mail id doesnt exist?

  • @mmkm-n4z
    @mmkm-n4z 2 місяці тому

    Thanks, this helped me a lot.

  • @ProjectCryo
    @ProjectCryo Рік тому

    Username and Password not accepted. Error code

  • @scale...3d
    @scale...3d Рік тому +1

    Ah, finally, it works. The good thing about this method is that I can use it with my main email rather than making a new one with security off.

    • @ThePyCoach
      @ThePyCoach  Рік тому

      I think that’s the reason why Google removed the other option

  • @palawanese1067
    @palawanese1067 2 роки тому +1

    How about sending with attachments?
    Great tutorial! Thank you.

  • @МаксимЮрків-б3о

    TY VERY MUCH BRO, YOU SOLVED MY PROBLEM

  • @impasible2783
    @impasible2783 7 місяців тому

    Thanks man! I was trying to figure the hell out when I was not getting my credentials right in the beginning. You perfectly explained the right way to get the password

  • @berkefekeskin9172
    @berkefekeskin9172 Рік тому

    Uh how can i add buttons in my email?

  • @ahrorkuldashev9603
    @ahrorkuldashev9603 8 місяців тому

    Great video! What is the port for?

  • @eugenefdscodes
    @eugenefdscodes Рік тому

    It doesn't work for me :/ I keep getting this error message:
    AttributeError: 'function' object has no attribute 'wrap_socket'
    It highlights the context=context line in my code.
    Does anyone have suggestions for fixing this?

    • @eugenefdscodes
      @eugenefdscodes Рік тому +1

      Lol I just forgot the parentheses "()" after the context = ssl.creat.... line 😅

  • @nickpollet1147
    @nickpollet1147 2 роки тому +1

    Hi Frank, amazing video. Can you upgrade this so you can send more a more complex body (like images etc).

  • @ubaidullah-tr8sv
    @ubaidullah-tr8sv Рік тому

    It always says : "ModuleNotFoundError: No module named 'email.message'; 'email' is not a package" please help me fix this

  • @Open4Didact
    @Open4Didact Рік тому

    It's works fine.Thanks