<commit_before>flask-sendgrid
==============

|PyPI version| |Travis Build| |Coverage Status|

Flask plugin for sending emails with `SendGrid`_.

Provides full support for all Twilio SendGrid `Web API v3`_ endpoints, including `v3 /mail/send`_.


Installation
------------

.. code-block:: bash

    pip install flask-sendgrid


Usage
-----

.. code-block:: python

    from flask_sendgrid import SendGrid
    app = Flask(__name__)
    app.config['SENDGRID_API_KEY'] = 'your api key'
    app.config['SENDGRID_DEFAULT_FROM'] = '<EMAIL>'
    mail = SendGrid(app)

    # send multiple recipients; backwards compatible with Flask-Mandrill
    mail.send_email(
        from_email='<EMAIL>',
        to_email=[{'email': '<EMAIL>'}, {'email': '<EMAIL>'}],
        subject='Subject'
        text='Body',
    )

    # send single recipient; single email as string
    mail.send_email(
        from_email='<EMAIL>',
        to_email='<EMAIL>',
        subject='Subject'
        text='Body',
    )

    # send single recipient; single email as sendgrid.mail.helpers.Email object
    mail.send_email(
        from_email='<EMAIL>',
        to_email=Email('<EMAIL>'),
        subject='Subject'
        text='Body',
    )

    # send multiple recipients; list of emails as sendgrid.mail.helpers.Email object
    mail.send_email(
        from_email='<EMAIL>',
        to_email=[Email('<EMAIL>'), Email('<EMAIL>')],
        subject='Subject'
        text='Body',
    )


For additional information about mail parameters: `SendGrid Web API
Mail`_<commit_msg>Update README.rst (#18)<commit_after>flask-sendgrid
==============

|PyPI version| |Travis Build| |Coverage Status|

Flask plugin for sending emails with `SendGrid`_.

Provides full support for all Twilio SendGrid `Web API v3`_ endpoints, including `v3 /mail/send`_.


Installation
------------

.. code-block:: bash

    pip install flask-sendgrid


Usage
-----

.. code-block:: python

    from flask_sendgrid import SendGrid
    app = Flask(__name__)
    app.config['SENDGRID_API_KEY'] = 'your api key'
    app.config['SENDGRID_DEFAULT_FROM'] = '<EMAIL>'
    mail = SendGrid(app)

    # send multiple recipients; backwards compatible with Flask-Mandrill
    mail.send_email(
        from_email='<EMAIL>',
        to_email=[{'email': '<EMAIL>'}, {'email': '<EMAIL>'}],
        subject='Subject',
        text='Body',
    )

    # send single recipient; single email as string
    mail.send_email(
        from_email='<EMAIL>',
        to_email='<EMAIL>',
        subject='Subject',
        text='Body',
    )

    # send single recipient; single email as sendgrid.mail.helpers.Email object
    mail.send_email(
        from_email='<EMAIL>',
        to_email=Email('<EMAIL>'),
        subject='Subject',
        text='Body',
    )

    # send multiple recipients; list of emails as sendgrid.mail.helpers.Email object
    mail.send_email(
        from_email='<EMAIL>',
        to_email=[Email('<EMAIL>'), Email('<EMAIL>')],
        subject='Subject',
        text='Body',
    )


For additional information about mail parameters: `SendGrid Web API
Mail`_
{'fraction_non_alphanumeric': 0.14673561732385262, 'fraction_numerical': 0.0019392372333548805, 'mean_word_length': 2.9376590330788805, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4243840', 'n_tokens_mistral': 969, 'n_tokens_neox': 944, 'n_words': 233}