Sending mails via python
<p>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 :</p>

<pre><code>echo "Test mail from postfix4" | mail -s "Test Postfix4" test@gmail.com
</code></pre>

<p>But when i tried to do the same via python i got error :</p>

<pre><code>&gt;&gt;&gt; from email.MIMEText import MIMEText
&gt;&gt;&gt; import smtplib
&gt;&gt;&gt; sender = 'test@mail.com'
&gt;&gt;&gt; to = 'test@gmail.com'
&gt;&gt;&gt; subj = "atata"
&gt;&gt;&gt; body = "ololo"
&gt;&gt;&gt; server = 'hostname'
&gt;&gt;&gt; msg = MIMEText(body, 'plain', 'utf-8')
&gt;&gt;&gt; msg['Subject'] = subj
&gt;&gt;&gt; msg['To'] = to
&gt;&gt;&gt; msg['Importance'] = 'high'
&gt;&gt;&gt; s = smtplib.SMTP(server)
&gt;&gt;&gt; s.sendmail(sender, [to], msg.as_string())
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/lib/python2.7/smtplib.py", line 742, in sendmail
    raise SMTPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'test@gmail.com': (454, '4.7.1 &lt;test@gmail.com&gt;: Relay access denied')}
&gt;&gt;&gt; s.quit()
(221, '2.0.0 Bye')
</code></pre>

<p>Can someone help me with it?</p>