python - smtplib.SMTPRecipientRefused error while sending email -
i have basic email code looks this:
#sendmail function send multiple attachments multiple users @ same time def sendmail(to, fro, subject, text, files=[], server="localhost"): assert type(to) == list assert type(files) == list msg = mimemultipart() msg['from'] = fro msg['to'] = commaspace.join(to) msg['date'] = formatdate(localtime=true) msg['subject'] = subject msg.attach(mimetext(text, 'html')) # print "obtained files:",files file in files: part = mimebase('application', "octet-stream") part.set_payload(open(file.strip(' '), "rb").read()) encoders.encode_base64(part) part.add_header('content-disposition', 'attachment; filename="%s"' % os.path.basename(file)) msg.attach(part) smtp = smtplib.smtp(server) smtp.sendmail(fro, to, msg.as_string()) smtp.close()
error receiving:
smtplib.smtprecipientsrefused: {'firstname.lastname@work.com': (553, '5.5.4 <firstname.lastname@work.com>... domain name required sender address a.b@work.com')}
what reason of following error , how can resolve same? have been stuck on since many hours !!! ps: my port 25 working , using python 2.7.9 , ubuntu 15.04
Comments
Post a Comment