2013-01-07 11 views
5

Sto tentando di inviare un'e-mail usando python ma nonostante io stia usando il server SMTP locale sembra che abbia bisogno di autenticazione. Il codice che corro e l'errore che ottengo può essere visto sotto. Io uso la porta 587, perché la porta 25 non può essere aperta sul mio server. Potresti aiutarmi a configurare il server SMTP locale usando python sulla porta 587?Python - smtp richiede l'autenticazione

>>> import smtplib 
>>> from email.mime.text import MIMEText 
>>> msg = MIMEText('Test body') 
>>> me = '[email protected]' 
>>> to = '[email protected]' 
>>> msg['Subject'] = 'My Subject' 
>>> msg['From'] = me 
>>> msg['To'] = to 
>>> s = smtplib.SMTP('localhost', 587) 
>>> s.sendmail(me, [to], msg.as_string()) 

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/lib/python2.7/smtplib.py", line 722, in sendmail 
    raise SMTPSenderRefused(code, resp, from_addr) 
smtplib.SMTPSenderRefused: (530, '5.7.0 Authentication required', '[email protected]') 
+2

Sì, la porta 587 richiede l'autenticazione. Avete una domanda? – tripleee

+0

C'è un modo per trovare le informazioni di autenticazione corrette per la porta 587? – Paris

+0

Sì, contattare l'amministratore del server. – tripleee

risposta