How to send newsletter from my pc? [closed]
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this questionIs there a way to send newsletter from my pc ( ubuntu 10.04 ) and python ?
maybe with a smtp library ?
If this is going to be a regular task, install Mailman (if you don't already have it) and learn how to use it.
Here is a script that can be used to send an email using a gmail or Google domain apps email account. It uses Google's SMTP server, so you don't need to configure one locally.
Using its 'mail' function, it's easy to send a message. For example:
# function signature: def mail(to, subject, text, attach)
mail("some.person@some.address.com",
"Hello from python!",
"This is a email sent with python",
"my_picture.jpg")
You could easily modify the 'mail' function to remove 'attach' if you don't want an attachment, or make it an optional keyword argument.
The simplest way is to pipe the output of your python program to the mail command on an appropriately configured system:
python my.py | mail -s "test mail sending" "your@email.com"
(For Ubuntu on your PC that probably means using the SMTP servers from your ISP as a smarthost for exim or another MTA)
If that doesn't cut it you're going to want to make your python script talk to some mailserver(s), usually using SMTP. There's a python library for this, see this question for an example generating MIME and probably others too.
精彩评论