I'm trying to send emails using yandex but my function doesn't work. It's just waiting forever there is no error either. Here is my function :
def send_emails(title,msg):
server = smtplib.SMTP('smtp.yandex.com.tr:465')
server.ehlo()
server.starttls()
server.login(yandex_mail,yandex_pass)
message = 'Subject: {}\n\n{}'.format(title,msg)
server.sendmail(yandex_mail,send_to_email,message)
server.quit()
print('E-mails successfully sent!')
send_emails('Test Mail', 'Yes its a test mail!')
i think your problem is here:
server = smtplib.SMTP('smtp.yandex.com.tr:465')
you need to use smtplib.SMTP_SSL because connection is security with SSL
docs, also smtplib.SMTP_SSL
get many params, first is host
and second is port
and other params, but you need now only this two, you need to give host
and port
separately, try this
def send_emails(title,msg):
server = smtplib.SMTP_SSL('smtp.yandex.com.tr', 465)
...