Tiny library to send email fluently
pip install fluentmail
or
python setup.py install
Works with Python 2.6+ and PyPy, tested by Travis-CI.
from fluentmail import *
mail = FluentMail('smtp.gmail.com', 587, TLS)
mail.credentials('[email protected]', 'pwd')\
.from_address('[email protected]')\
.to('[email protected]')\
.subject('FluentMail')\
.body(u'Hi, I\'m FluentMail.')\
.send()
from fluentmail import *
mail = FluentMail('smtp.gmail.com', 587, TLS)
mail.credentials('[email protected]', 'pwd')\
.from_address('[email protected]')\
.to('[email protected]')\
.to('[email protected]')\
.subject('FluentMail')\
.body(u'Hi, I\'m FluentMail.')\
.send()
or
from fluentmail import *
mail = FluentMail('smtp.gmail.com', 587, TLS)
mail.credentials('[email protected]', 'pwd')\
.from_address('[email protected]')\
.to(['[email protected]', '[email protected]'])\
.subject('FluentMail')\
.body(u'Hi, I\'m FluentMail.')\
.send()
from fluentmail import *
mail = FluentMail('smtp.gmail.com', 587, TLS)
mail.credentials('[email protected]', 'pwd')\
.from_address('[email protected]')\
.to('[email protected]')\
.cc('[email protected]')\
.bcc('[email protected]')\
.reply_to('[email protected]')\
.subject('FluentMail')\
.body(u'Hi, I\'m FluentMail.')\
.send()
from fluentmail import *
mail = FluentMail('smtp.gmail.com', 587, TLS)
mail.credentials('[email protected]', 'pwd')\
.from_address('[email protected]')\
.to('[email protected]')\
.subject('FluentMail')\
.body(u'<h2>Hi, I\'m FluentMail.<h2>')\
.as_html()\
.send()
from fluentmail import *
mail = FluentMail('smtp.gmail.com', 587, TLS)
mail.credentials('[email protected]', 'pwd')\
.from_address('[email protected]')\
.to('[email protected]')\
.subject('FluentMail')\
.body(u'<h2>Hi, I\'m FluentMail.<h2>', 'utf-8')\ # Body charset is optional.
.as_html()\
.attach('photo.png')\
.attach('description.txt', 'utf-8')\ # Charset is optional, and only for Text files.
.send()
from fluentmail import *
mail = FluentMail('smtp.gmail.com', security=SSL, credentials=('user', 'pwd'))
mail.body(u'<h2>Hi, I\'m FluentMail.<h2>', 'utf-8', True)
mail.send(from_address='[email protected]',
to=['[email protected]', '[email protected]'],
cc=[],
bcc=[],
reply_to=[],
subject='FluentMail')
mail = FluentMail('smtp.yoursite.com', 25, NON_ENCRYPTED)
mail = FluentMail('smtp.yoursite.com', 465, SSL)
mail = FluentMail('smtp.yoursite.com', 587, TLS)
By default SSL uses port 465, TLS uses 587 and AUTH 25.
For GMail you may want to read this security info.
Name | Server | Authentication | Port |
---|---|---|---|
Gmail | smtp.gmail.com | SSL | 465 |
Gmail | smtp.gmail.com | StartTLS | 587 |
Hotmail | smtp.live.com | SSL | 465 |
Mail.com | smtp.mail.com | SSL | 465 |
Outlook.com | smtp.live.com | StartTLS | 587 |
Office365.com | smtp.office365.com | StartTLS | 587 |
Yahoo Mail | smtp.mail.yahoo.com | SSL | 465 |
- Docs
- Unit tests
- Test with others SMTP providers