This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. General Coding and Design => Calculator Programming
Author Message

Advanced Member

Joined: 09 Oct 2007
Posts: 339

Posted: 26 Jun 2009 09:45:06 am    Post subject:

So yesterday I started learning Python. I wanted to try to send an email using Python, and looked around online for some stuff. The only good sources I found were scripts for sending emails with attachments. I don't want to add an attachment to the email. Here is the script I found:



import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email import encoders as Encoders
import os
import sys

GMAIL_PASSWD = "password"
SUBJECT = "Attached File: " + sys.argv[2]
MESSAGE = "A file is attached."

def mail(to, subject, text, attach):
   msg = MIMEMultipart()

   msg['From'] = GMAIL_USER
   msg['To'] = to
   msg['Subject'] = subject


   part = MIMEBase('application', 'octet-stream')
   part.set_payload(open(attach, 'rb').read())
           'attachment; filename="%s"' % os.path.basename(attach))

   mailServer = smtplib.SMTP("", 587)
   mailServer.login(GMAIL_USER, GMAIL_PASSWD)
   mailServer.sendmail(GMAIL_USER, to, msg.as_string())

mail(RECIPIENT, SUBJECT, MESSAGE, sys.argv[1])

I tried removing the code that mentioned attachments, but I got errors. What's the script to send an email without the attachment?
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours