Coder Social home page Coder Social logo

fluentmail's Introduction

fluentmail Build Status Version

Tiny library to send email fluently

Install

pip install fluentmail

or

python setup.py install

Compatibility

Works with Python 2.6+ and PyPy, tested by Travis-CI.

Usage

Basic

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()

To many receptors

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()

To, Cc, Bcc and Reply-To

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()

HTML Body

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()

With Attachment

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()

Being more Pythonic

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')

Authentication type

NON_ENCRYPTED

mail = FluentMail('smtp.yoursite.com', 25, NON_ENCRYPTED)

SSL

mail = FluentMail('smtp.yoursite.com', 465, SSL)

TLS

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.

Common smtp servers

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

TODO

  • Docs
  • Unit tests
  • Test with others SMTP providers

fluentmail's People

Contributors

afrancais avatar alexandrevicenzi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.