I tried to install and configure SMTP server. and it seems to me it happened. And when I send test mail from linux command line I receive mail, ex :
echo "Test mail from postfix4" | mail -s "Test Postfix4" test@gmail.com
But when i tried to do the same via python i got error :
>>> from email.MIMEText import MIMEText
>>> import smtplib
>>> sender = 'test@mail.com'
>>> to = 'test@gmail.com'
>>> subj = "atata"
>>> body = "ololo"
>>> server = 'hostname'
>>> msg = MIMEText(body, 'plain', 'utf-8')
>>> msg['Subject'] = subj
>>> msg['To'] = 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 someone help me with it?