Receive and send emails in python

Here is a very simple example:

import smtplib

server="mail.server.com"
user=""
password = ''

recipients = ['user@mail.com', 'other@mail.com']
sender="you@mail.com"
message="Hello World"

session = smtplib.SMTP(server)
# if your SMTP server doesn't need authentications,
# you don't need the following line:
session.login(user, password)
session.sendmail(sender, recipients, message)

For more options, error handling, etc, look at the smtplib module documentation.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)