0

Is there a way to send newsletter from my pc ( ubuntu 10.04 ) and python ?

maybe with a smtp library ?

xRobot
  • 25,579
  • 69
  • 184
  • 304

3 Answers3

2

If this is going to be a regular task, install Mailman (if you don't already have it) and learn how to use it.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
1

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.

naitsirhc
  • 5,274
  • 2
  • 23
  • 16
0

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.

Community
  • 1
  • 1
Flexo
  • 87,323
  • 22
  • 191
  • 272