Python Forum
[split] Script has stopped working
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Script has stopped working
#1
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")
Reply
#2
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).
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Help- converting file with pyton script eltomassito 6 3,190 Jul-02-2021, 05:29 PM
Last Post: snippsat
  Spyder stopped working in Windows 10 gammaray 3 3,030 Apr-19-2021, 05:33 PM
Last Post: jefsummers
  for loop script over telnet in Python 3.5 is not working abhijithd123 1 2,860 May-10-2020, 03:22 AM
Last Post: bowlofred
  [split] script: remove all "carriage return" from my json variable pete 2 2,742 May-05-2020, 03:22 PM
Last Post: deanhystad
  countdown script not working..plz help what is mistake randyjack 1 2,079 Oct-28-2019, 06:57 AM
Last Post: perfringo
  Pyautogui script runs fine if split into two parts together it does not Bmart6969 1 2,499 Oct-07-2019, 10:53 PM
Last Post: Bmart6969
  picamera not working on premade script georgeaura 1 2,479 Jul-24-2019, 10:11 AM
Last Post: gontajones
  python has stopped working sally 1 5,989 Nov-22-2018, 10:19 PM
Last Post: metulburr
  Split not working morgandebray 3 3,068 Aug-09-2018, 09:34 AM
Last Post: morgandebray
  mkdtemp spontaneously stopped working reliably last night saporta98 1 2,788 Apr-16-2018, 05:12 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020