title: Permission Denied error while sending mail using Python smtplib
body: <p>I am trying to send mail using Python 3.2. My code is as follows:</p>
  
  <pre><code>#from email import Encoders
  from email.mime.base import MIMEBase
  from email.mime.multipart import MIMEMultipart
  from email.mime.text import MIMEText
  from email.utils import COMMASPACE, formatdate
  import os
  import smtplib
  from base64 import encode
  from email import encoders
  
  def sendMail(to, subject, text, files=[],server="smtp.mydomain.com"):
      assert type(to)==list
      assert type(files)==list
      fro = "From &lt;myemail@mydomain.com&gt;"
  
      msg = MIMEMultipart()
      msg['From'] = fro
      msg['To'] = COMMASPACE.join(to)
      msg['Date'] = formatdate(localtime=True)
      msg['Subject'] = subject
  
      msg.attach( MIMEText(text) )
  
      for file in files:
          part = MIMEBase('application', "octet-stream")
          part.set_payload( open(file,"rb").read() )
          encoders.encode_base64(part)
          part.add_header('Content-Disposition', 'attachment; filename="%s"'
                         % os.path.basename(file))
          msg.attach(part)
  
      smtp = smtplib.SMTP_SSL(server, 465)
      smtp.ehlo()
      smtp.set_debuglevel(1)
      smtp.ehlo()
      smtp.login("myemail@mydomain.com", "mypassword")
      smtp.ehlo()
      smtp.sendmail(fro, to, msg.as_string() )
      smtp.close()
      print("Email send successfully.")
  
  sendMail(
          ["recipient"],
          "hello","cheers",
          []
      )
  </code></pre>
  
  <p>It gives me following error:</p>
  
  <pre><code>raise SMTPSenderRefused(code, resp, from_addr)
  smtplib.SMTPSenderRefused: (501, b'5.7.1 &lt;myemail@mydomain.com&gt;... Permission denied', 'myemail@mydomain.com')
  </code></pre>
  
  <p>Does anybody know how to solve this problem?</p>
  
  <p>Thanks in advance.</p>