email - Sending mails via python -
i tried install , configure smtp server. , seems me happened. , when send test mail linux command line receive mail, ex :
echo "test mail postfix4" | mail -s "test postfix4" test@gmail.com
but when tried same via python got error :
>>> email.mimetext import mimetext >>> import smtplib >>> sender = 'test@mail.com' >>> = 'test@gmail.com' >>> subj = "atata" >>> body = "ololo" >>> server = 'hostname' >>> msg = mimetext(body, 'plain', 'utf-8') >>> msg['subject'] = subj >>> msg['to'] = >>> msg['importance'] = 'high' >>> s = smtplib.smtp(server) >>> s.sendmail(sender, [to], msg.as_string()) traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/lib/python2.7/smtplib.py", line 742, in sendmail raise smtprecipientsrefused(senderrs) smtplib.smtprecipientsrefused: {'test@gmail.com': (454, '4.7.1 <test@gmail.com>: relay access denied')} >>> s.quit() (221, '2.0.0 bye')
can me it?
Comments
Post a Comment