0

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

maybe with a smtp library ?

xRobot
  • 22,700
  • 56
  • 163
  • 281

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
  • 81,234
  • 19
  • 144
  • 183
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
  • 3,726
  • 1
  • 21
  • 15
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
  • 82,006
  • 22
  • 174
  • 256