| | |
send email in python
![]() |
•
•
Join Date: Sep 2007
Posts: 24
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: 971
Reputation:
Solved Threads: 270
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 |
alarm anydbm app assignment beginner bluetooth character cipher cmd conversion coordinates corners curves customdialog cx-freeze data decimals definedlines development directory events excel exe feet file float format function generator getvalue gnu halp handling homework ideas input ip itunes keycontrol leftmouse line linux list lists loan loop maintain maze millimeter module mouse number numbers output parsing path prime programming push py2exe pygame pymailer python queue random rational raw_input recursion recursive schedule screensaverloopinactive script searchingfile slicenotation sqlite ssh string strings sudokusolver text time tlapse tooltip tuple type ubuntu unicode url urllib urllib2 variable ventrilo vigenere web webservice wikipedia word wxpython xlib xlwt






