0

Hi I am trying to send out an email through smtplib, I want to keep the username different from the login username. It is giving me an error when I used a shared mailbox which I do have the permission to send and revive emails and port number and works fine with smtp.office365.com.

Anyone know why?

Thank for your help.

server = smtplib.SMTP("ccc.ccccc.com", 88)  

server.ehlo()

server.starttls()

me = "xxxxxxx@xxx.com"

my_pwd = "xxxxxxxx"

you = ["xxxxxx@xxx.com"]

msg = MIMEMultipart('alternative')

msg['From'] = "yyyyyyyyy@yyy.com"
msg['To'] = ','.join(you)

body = MIMEText(html, 'html')

msg.attach(body)

server.login(me, my_pwd)

server.sendmail(me, you,msg.as_string())

server.quit()
Robᵩ
  • 163,533
  • 20
  • 239
  • 308
  • 1
    What is the full traceback – johnashu Feb 01 '18 at 19:45
  • SMTPDataError Traceback (most recent call last) in () 18 19 server.login(me, my_pwd) ---> 20 server.sendmail(me, you,msg.as_string()) 21 server.quit() /Users/tilin/anaconda/lib/python2.7/smtplib.pyc in sendmail(self, from_addr, to_addrs, msg, mail_options, rcpt_options) 749 if code != 250: 750 self.rset() --> 751 raise SMTPDataError(code, resp) 752 #if we got here then somebody got our mail 753 return senderrs – Tim Lin Feb 01 '18 at 22:05
  • SMTPDataError: (550, '5.7.1 Client does not have permissions to send as this sender') – Tim Lin Feb 01 '18 at 22:05
  • it may be that the mail server does not allow machine based sending.. anti spam..i think the problem is with the mail server persmissions.. maybe contactthem and ask. – johnashu Feb 01 '18 at 22:32

0 Answers0