| | |
send email in python
![]() |
•
•
Join Date: Sep 2007
Posts: 25
Reputation:
Solved Threads: 0
i have a python script and would like to know how to email the output of the script in python.
i can do it from the command line(kshell) with in *nix but would like something like this in the script.
somescript.py; echo "test" | mailx john_smith@xyz.com
i can do it from the command line(kshell) with in *nix but would like something like this in the script.
somescript.py; echo "test" | mailx john_smith@xyz.com
A very crude method would be to capture your output, and then execute the same command via os.system or a similar call.
Alternately you could make use of smtplib to send the email to a mail server's listener, and send it that way.
Example of using smtplib.
Keep in mind that in this example, the mail listening agent is on the same machine as the script is running. If this is not the case you'll need the ip address and port that the mail daemon is listening on of the server where this service is running.
Alternately you could make use of smtplib to send the email to a mail server's listener, and send it that way.
Example of using smtplib.
Keep in mind that in this example, the mail listening agent is on the same machine as the script is running. If this is not the case you'll need the ip address and port that the mail daemon is listening on of the server where this service is running.
Last edited by jlm699; Jul 23rd, 2008 at 12:27 pm.
•
•
Join Date: Dec 2006
Posts: 995
Reputation:
Solved Threads: 281
Something like the following is a simple example and usually works. If not, then you will have to Google for your specific sendmail app.
Python Syntax (Toggle Plain Text)
fromaddr = "<me@localhost>" toaddrs = "<you@localhost>" msg = "Test of Python's sendmail\n" # The actual mail send part server = smtplib.SMTP('localhost') server.set_debuglevel(1) server.sendmail(fromaddr, toaddrs, msg) print server.verify( toaddrs ) server.quit()
![]() |
Similar Threads
- Python Chat Server (Python)
- Open-Source Ajax/PHP (or Python) Webmail (Web Development Job Offers)
- c++ (sending email) (C++)
- python code security or set up a complied python code with a password (Python)
- Monitoring number of smtp bytes sent through python e-mail socket (Python)
- Boston Full-Time Job: Sr. Web Developer / Application Engineer (Web Development Job Offers)
- Full Time / Telecommute Python Programmer/s Sought (Software Development Job Offers)
- F/T Python Job in Utah (2) (Python)
- Telecommute Python Programmer $4,000 (USD) (Web Development Job Offers)
- Need help with a simple python program (Python)
Other Threads in the Python Forum
- Previous Thread: Defult (startup) Variables?
- Next Thread: webbrowser.open() opens absolute path +URL instead of URL
| Thread Tools | Search this Thread |
accessdenied advanced aliased anydbm argv beginner bits calling casino clear command conversion convert corners count csv cturtle cursor curves def definedlines dictionary digital dynamic dynamically enter event events excel external file float format frange function google handling homework i/o iframe import input jaunty keyboard lapse line linux list lists loan loop matching mouse multiple newb number numbers obexftp output parsing path prime programming projects py py2exe pygame python random rational raw_input recursion recursive return searchingfile signal singleton skinning string strings tails text threading time tlapse tooltip tuple tutorial type ubuntu unicode urllib urllib2 valueerror variable voip web-scrape whileloop word wxpython






