I'm trying to send email using Django on localhost, but it's giving me the below error.
SMTPException at /listings No suitable authentication method found
This is my function:
send_mail(
'Subject here',
'Here is the message.',
'emailfrom',
['emailto'],
auth_user='username',
auth_password='password',
)
And this is my settings:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mail.etisalat.com'
EMAIL_HOST_USER = 'myemail'
EMAIL_HOST_PASSWORD = 'mypassword'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
I am using like this and it works
from email.message import EmailMessage
import smtplib
msg = EmailMessage()
msg.set_content(my_content)
me = config.email
you = toList
msg['Subject'] = subject
msg['From'] = me
msg['To'] = you
with open(excel_file, 'rb') as f:
file_data = f.read()
msg.add_attachment(file_data, maintype="application", subtype="csv", filename=excel_file)
s = smtplib.SMTP("host.com", 587)
s.ehlo()
s.starttls()
s.login(config.email, config.password)
s.send_message(msg)
s.quit()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.