Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send email in Python like PHP

I noticed that php just has one quick function to send emails and I'm wondering if I can do that in Python. I know that Python has an email module, but I understand that I need to be running an SMTP server to use that, whereas PHP can use sendmail.

I would preferably like to use Python 3 and any help on this would be much appreciated.

like image 576
Tom Leese Avatar asked Jun 26 '11 17:06

Tom Leese


1 Answers

this is a full tutorial for sending email in python..it looks like they do have sendmail function too..take a look at

try:
   smtpObj = smtplib.SMTP('localhost')
   smtpObj.sendmail(sender, receivers, message)         
   print "Successfully sent email"
except SMTPException:
   print "Error: unable to send email"
like image 187
Benny Tjia Avatar answered Oct 03 '22 02:10

Benny Tjia