Python send an email 📧

Поделиться
HTML-код
  • Опубликовано: 31 янв 2021
  • python send an email tutorial example explained
    #python #email #send
    ****************************************************************
    Python email
    ****************************************************************
    import smtplib
    sender = "sender@gmail.com"
    receiver = "receiver@gmail.com"
    password = "password123"
    subject = "Python email test"
    body = "I wrote an email! :D"
    header
    message = f"""From: Snoop Dogg{sender}
    To: Nicholas Cage{receiver}
    Subject: {subject}

    {body}
    """
    server = smtplib.SMTP("smtp.gmail.com", 587)
    server.starttls()
    try:
    server.login(sender,password)
    print("Logged in...")
    server.sendmail(sender, receiver, message)
    print("Email has been sent!")
    except smtplib.SMTPAuthenticationError:
    print("unable to sign in")
    ****************************************************************
    Bro Code merch store 👟 :
    ===========================================================
    teespring.com/stores/bro-code-5
    ===========================================================
    music credits 🎼 :
    ===========================================================
    Up In My Jam (All Of A Sudden) by - Kubbi / kubbi
    Creative Commons - Attribution-ShareAlike 3.0 Unported- CC BY-SA 3.0
    Free Download / Stream: bit.ly/2JnDfCE
    Music promoted by Audio Library • Up In My Jam (All Of A...
    ===========================================================
  • НаукаНаука

Комментарии • 55

  • @BroCodez
    @BroCodez  3 года назад +6

    (If you have 2-Factor Authentication set up on your account, that may prevent you from logging in from an unknown device)
    # ****************************************************************
    # Python email
    # ****************************************************************
    import smtplib
    sender = "sender@gmail.com"
    receiver = "receiver@gmail.com"
    password = "password123"
    subject = "Python email test"
    body = "I wrote an email! :D"
    # header
    message = f"""From: Snoop Dogg{sender}
    To: Nicholas Cage{receiver}
    Subject: {subject}

    {body}
    """
    server = smtplib.SMTP("smtp.gmail.com", 587)
    server.starttls()
    try:
    server.login(sender,password)
    print("Logged in...")
    server.sendmail(sender, receiver, message)
    print("Email has been sent!")
    except smtplib.SMTPAuthenticationError:
    print("unable to sign in")
    # ****************************************************************

  • @andromydous
    @andromydous 2 года назад +35

    If anyone is trying this now, Google has removed that security step. You now have to go into the section of the Security called App Password. You just give your app a name and click on "generate". You then replace the value for "password" with the auto generated one. I sent my wife 2 emails. Once to see if it really works and the second time was when I showed her how simple the code was.

    • @trungdu9354
      @trungdu9354 2 года назад +1

      or if you know assembly ARM MASM NASM you can also do SSH socket email and there was another i forgot the other way prob thru TCIP or UDP been a while since I looked at assembly it was a pain to go thru many steps to just move data around

    • @rottenapple7373
      @rottenapple7373 2 года назад +1

      This works and is really easy to do. Thanks for the tip!!!

    • @sune2639
      @sune2639 Год назад +1

      It worked! TYSM!!!

    • @noum3877
      @noum3877 Год назад +1

      SOS.
      It is not working for me.
      Checked many times correctness of the writing, then I gave app name to my gmail, clicked on generate, replaced my password to generated 16-digit number in my "password".
      But, still getting this type of message:
      smtplib.SMTPServerDisconnected: Connection unexpectedly closed: [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

    • @StefanStd
      @StefanStd Год назад

      Also need to be enabled the 2FA or two factor authentication!, so "App Passwords" section appear in Google account

  • @arpanshah355
    @arpanshah355 Год назад +5

    5:58 - "some of you guys are weird" 🤣🤣🤣

  • @chalkypj
    @chalkypj Год назад

    Your tutorials are always great

  • @Alex-ur3vt
    @Alex-ur3vt 3 года назад +3

    You make the best videos , Bro.

  • @VoVanHung97
    @VoVanHung97 2 года назад

    Thank you very very much, you help me learn more about python.
    God luck to you

  • @jhassee
    @jhassee Год назад

    i dont see myself every going out my way to send an insecure email, but still great info for projects that may have these sorts of communications in regards, thanks bro!

  • @shahzodsayfiddinov9510
    @shahzodsayfiddinov9510 3 года назад

    Thank you Bro!

  • @soroshroshantab5590
    @soroshroshantab5590 2 года назад

    Thanks 🙏👍

  • @rau149
    @rau149 2 года назад

    Cool

  • @ultimatelegoman1279
    @ultimatelegoman1279 2 года назад

    its my broooo

  • @Buddygmusic
    @Buddygmusic Год назад

    COOL

  • @xcorpionxyed2078
    @xcorpionxyed2078 2 года назад +4

    hey bro google has turned "less secure app" off permenetaly, last month, anyother way to send emails using python ????

    • @sudaiskhan653
      @sudaiskhan653 7 месяцев назад

      Yeah, App Passwords in google security section, if its not there check if 2FA is on (2 Factor Authentication) if 2FA is on, and you still can't seem to find it just search it in "Search Google Account."

  • @ThinhTran-iv4xl
    @ThinhTran-iv4xl Год назад +1

    Less secure app access is no longer available right now. What can i do to send email in python ? Help me please

  • @idevsl8245
    @idevsl8245 3 года назад +1

    That video much more interesting than previous.

    • @frezywizard
      @frezywizard 2 года назад

      It's not really about being interesting its about learning useful stuff

  • @nareshpolavarapu5262
    @nareshpolavarapu5262 2 года назад

    Hi, is there any method to send an email with "On Behalf Of " another address in from address by using python-smtplib?

  • @provokator-provocateur7603
    @provokator-provocateur7603 2 года назад +1

    4:57 -
    I'll blame you if I'm hacked anyway. 😁😂

  • @oguzhantopaloglu9442
    @oguzhantopaloglu9442 3 года назад

    📧📧📧📧📧

  • @davimartins1703
    @davimartins1703 3 года назад +5

    oi, bro eu estou tendo um problema aparece esse erro pra mim: "AttributeError: partially initialized module 'smtplib' has no attribute 'SMTP' (most likely due to a circular import)"

    •  2 года назад +1

      Tive o msm problema. Vc n pode nomear nem o arquivo nem a pasta do projeto de Email

  • @detectivedoom5175
    @detectivedoom5175 2 года назад +1

    Video needs updating since Google screwed up their security thing, we can't send stuff anymore...

  • @BTSarmy-xn8yg
    @BTSarmy-xn8yg 3 года назад +1

    Hey man

    • @BTSarmy-xn8yg
      @BTSarmy-xn8yg 3 года назад

      Hey man you know india

    • @BTSarmy-xn8yg
      @BTSarmy-xn8yg 3 года назад

      Bro how are you learning all programming languages plz tell me

  • @Oof_the_gamer
    @Oof_the_gamer 2 месяца назад

    Does anyone know if other sending applications (like outlook) can work with this module?

  • @arpanshah355
    @arpanshah355 Год назад

    i miss the old bro code outro music 😢😢

  • @minecraftguides7760
    @minecraftguides7760 3 года назад

    Will you do this in java too?

  • @nerdface1260
    @nerdface1260 Год назад

    I can swear my suprviser and when he looks at me I am not sending him anything

  • @dustinoliver8348
    @dustinoliver8348 Год назад

    If I use python to send a subscription email, how do I get the bottom of the email to go to a link where someone can unsubscribe?

  • @Vortex95
    @Vortex95 Год назад

    how to mail files with python ?

  • @mohammadrazalp.p2361
    @mohammadrazalp.p2361 3 года назад +1

    How to send malayalam is any possible way to send

    • @oguzhantopaloglu9442
      @oguzhantopaloglu9442 3 года назад +1

      Wtf is malayalam?

    • @mohammadrazalp.p2361
      @mohammadrazalp.p2361 3 года назад

      @@oguzhantopaloglu9442 malayalam is kerala language

    • @MK-zf6or
      @MK-zf6or 3 года назад

      just type in malayam in the string of what ur sending on the email

    • @mohammadrazalp.p2361
      @mohammadrazalp.p2361 3 года назад

      @@MK-zf6or its not sending and show some error message

    • @MK-zf6or
      @MK-zf6or 3 года назад +1

      @@mohammadrazalp.p2361 crap bro, just try hindi or urdu then maybe

  • @bigfatpepe
    @bigfatpepe 2 года назад

    time to spam!

  • @shricharanramesh7149
    @shricharanramesh7149 Месяц назад

    Bro now its now working

  • @arpanshah355
    @arpanshah355 Год назад

    comment

  • @Oof_the_gamer
    @Oof_the_gamer 2 месяца назад

    someone help me, I keep getting error: smtplib.SMTPServerDisconnected: Connection unexpectedly closed
    bottom text

  • @zstar8397
    @zstar8397 7 месяцев назад

    Hey hope you are doing alright just I wanna say that
    GOD loved the world so much he sent his only begotten
    son Jesus to die a brutal death for us so that we can have eternal life and we can all accept this amazing gift this by simply trusting in Jesus, confessing that GOD raised him from the dead, turning away from your sins and forming a relationship with GOD.