web-dev-qa-db-fra.com

Comment envoyer un e-mail sans connexion au serveur dans Python

Je veux envoyer un e-mail sans connexion au serveur en Python. J'utilise Python 3.6. J'ai essayé du code mais j'ai reçu une erreur. Voici mon code:

import smtplib                          

smtpServer='smtp.yourdomain.com'      
fromAddr='[email protected]'         
toAddr='[email protected]'     
text= "This is a test of sending email from within Python."
server = smtplib.SMTP(smtpServer)
server.set_debuglevel(1)         
server.sendmail(fromAddr, toAddr, text) 
server.quit()

Je m'attends à ce que le courrier soit envoyé sans demander l'ID utilisateur et le mot de passe mais obtenir une erreur:

"smtplib.SMTPSenderRefused: (530, b'5.7.1 Le client n'a pas été authentifié ',' [email protected] ')"

3
Omkar
import win32com.client as win32
Outlook=win32.Dispatch('Outlook.application')
mail=Outlook.CreateItem(0)
mail.To='To address'
mail.Subject='Message subject'
mail.Body='Message body'
mail.HTMLBody='<h2>HTML Message body</h2>' #this field is optional

# To attach a file to the email (optional):
attachment="Path to the attachment"
mail.Attachments.Add(attachment)

mail.Send()
0
shivam sharma