Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
send email smtp
#1
I am trying to send email from python using smtp and yahoo. is there special settings like gmail in yahoo?

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

 server = smtplib.SMTP('smtp.mail.yahoo.com',587) #smtp,port number
  server.ehlo()
  server.starttls()
  server.ehlo()
  server.login("[email protected]","mypassword")
  fromaddr = "[email protected]"
  toaddr = "[email protected]"
  subject = "From Python"
  msg = MIMEMultipart()
  msg['From'] = fromaddr
  msg['To'] = toaddr
  msg['Subject'] = subject
  body = "Sent from Python"
  msg.attach(MIMEText(body, 'plain'))
  text = msg.as_string()
  server.sendmail(fromaddr, toaddr, text)
I am getting:
raise SMTPServerDisconnected("Connection unexpectedly closed")
buran write Jun-19-2021, 06:26 AM:
I removed the attached image because your e-mail and password was visible in the traceback. You may want to change your password.
Also, don't post images of code, error, input, output, etc. Copy/paste as text and using proper tags.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Send email with smtp without using Mimetext mgallotti 0 678 Feb-01-2023, 04:43 AM
Last Post: mgallotti
  email Library: properly send message as quoted-printable malonn 3 1,267 Nov-14-2022, 09:31 PM
Last Post: malonn
  Unable to send email attachments cosmarchy 7 2,444 Mar-09-2022, 09:29 PM
Last Post: bowlofred
  How to make scraper send email notification just once themech25 0 1,362 Nov-08-2021, 01:51 PM
Last Post: themech25
  Need Outlook send email code using python srikanthpython 3 8,092 Feb-28-2021, 01:53 PM
Last Post: asyswow64
  How to send email using python? Gigux 2 2,784 Jul-04-2020, 07:53 AM
Last Post: Gigux
  I am trying to send an email with python nick235 9 5,202 Jun-29-2020, 06:40 PM
Last Post: nick235
  TimeOutError when trying to initiate smtplib.SMTP thecosmos 0 3,295 Jun-19-2020, 05:30 AM
Last Post: thecosmos
  SMTP problem MajK 6 3,086 May-09-2020, 07:47 AM
Last Post: MajK
  Sending an email with attachment without using SMTP? PythonNPC 5 3,115 May-05-2020, 07:58 AM
Last Post: PythonNPC

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020