| | |
send email in python
![]() |
•
•
Join Date: Sep 2007
Posts: 28
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: 1,187
Reputation:
Solved Threads: 341
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
Views: 3880 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Python
application array beginner c++ c/c++ change character class client code command convert count create ctypes database def dictionary directory django dll error examples excel exe extensions fdlib file float format framework ftp function graphics gui heads homework image images import input library line linux list lists logging loop loops maze module mouse mysql mysqldb number numbers output parsing path permissions port prime processing program programming pure_virtual py2exe pygame pygtk pyqt python recursion recursive redirect remote reverse scrolledtext server socket ssh stdout string strings table terminal text thread threading tkinter transparency tuple tutorial ubuntu unicode urllib variable variables web windows wxpython






