[split] Script has stopped working - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: [split] Script has stopped working (/thread-2220.html) |
[split] Script has stopped working - santhosh - Feb-27-2017 hello everyone i am using this script for mail sending it will sending through gmail but i am unable to send through my office mail (smtp) i am sending gmail to office but i am unable to send office mail to office or outside mail can you help me any once ----------------------------------------------------------------------------------------------------------------------------------------------------------- import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.MIMEText import MIMEText from email import Encoders import os gmail_user = " [email protected]" gmail_pwd = "password" def mail(to, subject, text, attach): msg = MIMEMultipart() msg['From'] = gmail_user msg['To'] = to msg['Subject'] = subject msg.attach(MIMEText(text)) part = MIMEBase('application', 'octet-stream') part.set_payload(open(attach, 'rb').read()) Encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(attach)) msg.attach(part) mailServer = smtplib.SMTP("smtp.gmail.com", 587) mailServer.ehlo() mailServer.starttls() mailServer.ehlo() mailServer.login(gmail_user, gmail_pwd) mailServer.sendmail(gmail_user, to, msg.as_string()) # Should be mailServer.quit(), but that crashes... mailServer.close() mail("[email protected]", "Beeam line up!", "This is a email sent with python Beeam lines UP Please check", "my_picture.jpg") RE: [split] Script has stopped working - Ofnuts - Feb-27-2017 Without the actual error(s) it is hard to help. It is more likely a problem of authentication. Have you tried to send mail under these various conditions outside of Python (command-line mail client, or simple GUI mail client, which isn't your usual mail client). |