| | |
send email in python
![]() |
•
•
Join Date: Sep 2007
Posts: 27
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,135
Reputation:
Solved Threads: 326
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: 3661 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Python
anydbm app application beginner change character cipher class client code coordinates curves database development dictionary dynamic embedding examples excel exe feet file float format ftp function generator gui handling homework idiocy images import input ironpython java keycontrol library line linux list lists loop module mouse mysql mysqldb newb number numbers output parsing path port prime processing program programming projects py2exe pygame pygtk pymailer pyqt python random recursion recursive redirect reverse scrolledtext server split ssh stdout string strings table terminal text thread threading time tkinter tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 variable web windows wx.wizard wxpython xlwt






