Giter VIP home page Giter VIP logo

sendgrid-django's Introduction

SendGrid-django

Travis CI

codecov.io

Simple django backend to send email using SendGrid's Web API.

Installation

Install the backend from PyPI:

pip install sendgrid-django

Add the following to your project's settings.py:

EMAIL_BACKEND = "sgbackend.SendGridBackend"
SENDGRID_API_KEY = "Your SendGrid API Key"

Done!

Example

from django.core.mail import send_mail
from django.core.mail import EmailMultiAlternatives

send_mail("Your Subject", "This is a simple text email body.",
  "Yamil Asusta <[email protected]>", ["[email protected]"])

# or
mail = EmailMultiAlternatives(
  subject="Your Subject",
  body="This is a simple text email body.",
  from_email="Yamil Asusta <[email protected]>",
  to=["[email protected]"],
  headers={"Reply-To": "[email protected]"}
)
# Add template
mail.template_id = 'YOUR TEMPLATE ID FROM SENDGRID ADMIN'

# Replace substitutions in sendgrid template
mail.substitutions = {'%username%': 'elbuo8'}

# Attach file
with open('somefilename.pdf', 'rb') as file:
    mail.attachments = [
        ('somefilename.pdf', file.read(), 'application/pdf')
    ]

# Add categories
mail.categories = [
    'work',
    'urgent',
]

mail.attach_alternative(
    "<p>This is a simple HTML email body</p>", "text/html"
)

mail.send()

To create an instance of a SendGridBackend with an API key other than that provided in settings, pass api_key to the constructor

from sgbackend import SendGridBackend
from django.core.mail import send_mail

connection = SendGridBackend(api_key='your key')

send_mail(<subject etc>, connection=connection)

License

MIT

Enjoy :)

Development

Install dependencies::

pip install -r requirements-dev.txt

Run the tests with coverage::

pytest --cov=sgbackend

If you see the error "No module named sgbackend", run::

pip install -e .

sendgrid-django's People

Contributors

ameng avatar andriisoldatenko avatar camflan avatar dbohomiakov avatar devrishik avatar dmitry-saritasa avatar elbuo8 avatar hvjohnf avatar jonblum avatar jonklo avatar jschneier avatar kavdev avatar kregoslup avatar martey avatar matiboy avatar neob91 avatar pandabearcoder avatar rsniezynski avatar szumo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sendgrid-django's Issues

Installation fails with python 3.4

Hi Guys,

(python3)[root@backend app]# pip install sendgrid-django==1.3.0
Collecting sendgrid-django==1.3.0
  Downloading sendgrid-django-1.3.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-cldgmrut/sendgrid-django/setup.py", line 16, in <module>
        long_description=open('./README.rst').read(),
      File "/home/www/.virtual/python3/lib/python3.4/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 83: ordinal not in range(128)

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-cldgmrut/sendgrid-django
(python3)[root@backend app]# pip install sendgrid-django       
Collecting sendgrid-django
  Using cached sendgrid-django-1.3.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-9u9wc2e6/sendgrid-django/setup.py", line 16, in <module>
        long_description=open('./README.rst').read(),
      File "/home/www/.virtual/python3/lib/python3.4/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 83: ordinal not in range(128)

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9u9wc2e6/sendgrid-django

Tag releases in Git(Hub)

There have been quite a few releases of sendgrid-django, as indicated by PyPI, but these releases don't appear to be tagged on GitHub. For those of us who don't upgrade as fast as everyone else, this makes it difficult to hunt down the source for our version of the package when we want to view it on GitHub.

Would it be possible for a tag to be created or a release to be created for future versions of sendgrid-django, to make it easier to track down versions of the package and compare them?

Celery - Task handler raised error: MaybeEncodingError ?

Hi guys!

Does sendgrid-django works well with Celery?

celery==4.0.2
sendgrid==3.6.3
sendgrid-django==4.0.4
# -*- coding: utf-8

import smtplib
from email.mime.text import MIMEText

from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template
from rotina_contabil.settings import SEND_SENDGRID_MAIL
from rotina_contabil.settings import EMAIL_USER, PASS_USER

def send_email(subject, _from, _to, template, data):

    template = get_template(template)
    html_content = template.render(data)

    mail = EmailMultiAlternatives(
        subject=subject,
        body=str(data),
        from_email=_from,
        to=[_to],
        reply_to=['Rotina Contábil <[email protected]>']
    )

    mail.attach_alternative(html_content, "text/html")
    mail.send()
[2017-07-03 11:54:03,442: ERROR/PoolWorker-2] Task utilidades.tasks.async_send_email[b64bf98f-77ad-4c87-85c6-1cf7dcbc2eb4] raised unexpected: BadRequestsError('HTTPError()',)
Traceback (most recent call last):
  File "/home/junkemen/Documents/pinewoods/99contatores/env34/lib/python3.4/site-packages/celery/app/trace.py", line 367, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/junkemen/Documents/pinewoods/99contatores/env34/lib/python3.4/site-packages/celery/app/trace.py", line 622, in __protected_call__
    return self.run(*args, **kwargs)
  File "/home/junkemen/Documents/pinewoods/99contatores/rotina_contabil/utilidades/tasks.py", line 8, in async_send_email
    send_email(*args, **kwargs)
  File "/home/junkemen/Documents/pinewoods/99contatores/rotina_contabil/utilidades/email.py", line 43, in send_email
    mail.send()
  File "/home/junkemen/Documents/pinewoods/99contatores/env34/lib/python3.4/site-packages/django/core/mail/message.py", line 292, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/home/junkemen/Documents/pinewoods/99contatores/env34/lib/python3.4/site-packages/sgbackend/mail.py", line 68, in send_messages
    self.sg.client.mail.send.post(request_body=mail)
  File "/home/junkemen/Documents/pinewoods/99contatores/env34/lib/python3.4/site-packages/python_http_client/client.py", line 211, in http_request
    return Response(self._make_request(opener, request))
  File "/home/junkemen/Documents/pinewoods/99contatores/env34/lib/python3.4/site-packages/python_http_client/client.py", line 145, in _make_request
    raise exc
python_http_client.exceptions.BadRequestsError: HTTPError()
[2017-07-03 11:54:03,472: ERROR/MainProcess] Task handler raised error: <MaybeEncodingError: Error sending result: '"(1, <ExceptionInfo: BadRequestsError('HTTPError()',)>, None)"'. Reason: ''PicklingError("Can\'t pickle <class \'python_http_client.exceptions.BadRequestsError\'>: it\'s not the same object as python_http_client.exceptions.BadRequestsError",)''.>
Traceback (most recent call last):
  File "/home/junkemen/Documents/pinewoods/99contatores/env34/lib/python3.4/site-packages/billiard/pool.py", line 363, in workloop
    put((READY, (job, i, result, inqW_fd)))
  File "/home/junkemen/Documents/pinewoods/99contatores/env34/lib/python3.4/site-packages/billiard/queues.py", line 366, in put
    self.send_payload(ForkingPickler.dumps(obj))
  File "/home/junkemen/Documents/pinewoods/99contatores/env34/lib/python3.4/site-packages/billiard/reduction.py", line 56, in dumps
    cls(buf, protocol).dump(obj)
billiard.pool.MaybeEncodingError: Error sending result: '"(1, <ExceptionInfo: BadRequestsError('HTTPError()',)>, None)"'. Reason: ''PicklingError("Can\'t pickle <class \'python_http_client.exceptions.BadRequestsError\'>: it\'s not the same object as python_http_client.exceptions.BadRequestsError",)''.

Sending emails with attachements does not work well when using this library

Hi,

I used to send HTML emails with SMTP via sendgrid. But unfortunately, had to switch back to webapi due to some client issue. When i use sendgrid-django, to send these emails, the attachments end up being malformed.

Here's a snippet of my django code which is sending out HTML emails with attachements:

# To attach the image inline.
  msg = EmailMultiAlternatives(subject, text_content, from_email, to_email)
  msg.attach_alternative(html_content, "text/html")
  msg.mixed_subtype = 'related'

  fp = open(IMAGE_PATH+ imgName, 'rb')
  msg_img = MIMEImage(fp.read(), name=imgName)
  fp.close()
  msg_img.add_header('Content-ID', '<{0}>'.format(imgName))
  msg.attach(msg_img)

And then i use send_messages() to send out these messages.

In the email that gets sent out, the attachments seem to be malformed. Am i missing something ?

Appreciate your help.

Remove `sendgrid_api_key` dependency from Settings

  • I am working on this library . And I was thinking of using your libray for SendGrid, But you have a strong dependency of mentioning Send_Grid_API in settings.

  • If you can make it possible that user can either mention api_key in settings or pass it as function argument too (If you think its feasible and makes sense).

  • Why Remove Settings dependency ?

    • So that user can use as many service as he wants by simple passing the key in Function and let function do the rest of work.

Lacking compatibility with lazy-translated strings

When preparing the HTTP POST request for sending email via the API, JSON serialization fails when attempting to serialize django.utils.functional.__proxy__ objects (strings that have yet to be translated).

Potential wrap-around fix is to force JSON encoding with an encoder that forces all objects to unicode before attempting to serialize.

Error encountered:

TypeError: Object of type '__proxy__' is not JSON serializable

Source of the issue:

# sgbackend/mail.py line 68, in send_messages:
    self.sg.client.mail.send.post(request_body=mail)

Similar issues:
ryanbagwell/django-cms-named-menus#2

Sendgrid Templates Integration

Is it possible to use a template from my sendgrid account with this library? I ask because the example code on the github for this library uses django.core.mail code and im not sure how to pass the template id as recommended in the sendgrid documentation.

Version 4.2.0 - Email comes without template

My env:
Django: 1.11.29
Python: 2.7.18
sendgrid-django: 4.2.0
I changed settings:

EMAIL_BACKEND = "sgbackend.SendGridBackend"
SENDGRID_API_KEY = 'api key'

And used a code sample from the example:

    mail = EmailMultiAlternatives(
        subject="Your Subject",
        body="This is a simple text email body.",
        from_email="company <[email protected]>",
        to=["[email protected]"],
    )
    mail.template_id = '6b02f312-ad80-4d7e-815a-24be029fd05b'

    mail.substitutions = {
        '%email%': 'some email',
        '%location_city%': 'some city',
    }

    mail.send()

Email is coming, but without template

Advice on how to achieve per-email-sent clicktracking toggle?

We have use cases where we need to be able to disable clicktracking on a per-email-sent basis and I'm struggling a bit on figuring out how to achieve that with our current sendgrid integration through this package.

I see in the tests provided there is support for sending extra headers but you don't use a header which makes sense outside of a test so that has me curious whether these extra headers supported includes the X-SMTPAPI header provided from sendgrid's SMTP API?
This should allow us to use the SMTP API settings filters on a per-email-sent basis if that is the case.

SSL Verification Failure on Docker Alpine Python 3.5

We are trying to get setup with Send Grid using this library and receiving the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/lib/python3.5/site-packages/celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
  File "/var/doorman/communication/tasks.py", line 34, in send
    mail.send()
  File "/usr/lib/python3.5/site-packages/django/core/mail/message.py", line 342, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/lib/python3.5/site-packages/sgbackend/mail.py", line 68, in send_messages
    self.sg.client.mail.send.post(request_body=mail)
  File "/usr/lib/python3.5/site-packages/python_http_client/client.py", line 204, in http_request
    return Response(self._make_request(opener, request))
  File "/usr/lib/python3.5/site-packages/python_http_client/client.py", line 138, in _make_request
    return opener.open(request)
  File "/usr/lib/python3.5/urllib/request.py", line 466, in open
    response = self._open(req, data)
  File "/usr/lib/python3.5/urllib/request.py", line 484, in _open
    '_open', req)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 1297, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.5/urllib/request.py", line 1256, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)>

Our setup is:

  • Django 1.10
  • Python 3.5
  • Docker
  • Alpine OS (latest)

User Agent Tracking

@thinkingserious would it make sense for you if we overrode the user-agent header with one that indicates traffic for this library? Would be nice to get some usage statistics. We would use the same format of course.

Thoughts @andriisoldatenko ?

Applying group data to Mail object

I've been digging through the source and cannot find a way of sending
"asm": {"group_id": 1} along the request in order to associate a specific unsubscribe link to the user in the mail being sent.

Is this possible? If not, why? And what about all of the other fields in the v3 /mail/send endpoint?

Wheel support

http://pythonwheels.com/

Right now, only the tar.gz file is being distributed on PyPI for sendgrid-django, which isn't that much of an issue, but it does add some time to installing the package.

This package should be compatible with the Wheel format, considering it doesn't appear to have any C dependencies and it is compatible with both Python 2 and 3. As a result, you should only need to generate a universal wheel and then everyone (on all systems) will get the ability to install sendgrid-django with just the wheel, without having to do any extra work.

sendgrid.exceptions.SendGridServerError

Hi,

trying to send email
getting this request:
sendgrid.exceptions.SendGridServerError: (500, b'{"message": "error", "errors": ["Invalid Request"]}')

my settings.py

EMAIL_BACKEND = "sgbackend.SendGridBackend"
DEFAULT_FROM_EMAIL = "[email protected]"
SENDGRID_USER = "login"
SENDGRID_PASSWORD = "password"

my code fails with exception above

from_email = settings.DEFAULT_FROM_EMAIL
         subject = _(u"Verification code")
         to = ('[email protected]',)

         text_content = "Your verification code is: "
         html_content = "Your verification code is :<b>{}</b>".format(instance.emailcode)

         send_mail(subject, text_content, from_email,
                   to, fail_silently=False, html_message=html_content)

Exception Location: lib\site-packages\sendgrid\sendgrid.py in _raising_send, line 133
Python Executable: .venv\project\Scripts\python.exe
Python Version: 3.4.2
Django Version: 1.8.3
SendGrid Version: 1.4.0

what am I doing wrong?

'Mail' object has no attribute 'set_from' on sendgrid==4.2.0

When using:

sendgrid==4.2.0
sendgrid-django==4.0.4
django=1.11.2

whenever I want to send e-mail I got error:

File "/app/.heroku/python/lib/python3.6/site-packages/django/core/mail/message.py" in send
  348.         return self.get_connection(fail_silently).send_messages([self])

File "/app/.heroku/python/lib/python3.6/site-packages/sgbackend/mail.py" in send_messages
  66.             mail = self._build_sg_mail(email)

File "/app/.heroku/python/lib/python3.6/site-packages/sgbackend/mail.py" in _build_sg_mail
  82.         mail.set_from(Email(from_email, from_name))

Exception Type: AttributeError at /auth/password/reset/
Exception Value: 'Mail' object has no attribute 'set_from'

Downgrading to sendgrid==3.6.3 solves issue.

Unit tests and code coverage

I would like to propose to start writing tests, add code coverage and small testing on different python versions to avoid issues.

TODO:

#46

Issues When attaching file with email in sendgrid v3 APIs

  • I was using this package for sending email with sendgrid. Everything was working fine but some days ago one of my email where I attach an excel sheet started raising errors.

  • On debugging I find out that it was because of new Behaviour of sendgrid V3 APIs.

  • The issue I was getting is bad Request error. Complete error is as follows :

{'errors': [{'message': 'The content value must be a string at least one character in length.', 'help': 'http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content.value', 'field': 'content.0.value'}]}

  • Seems kile sendgrid don't accept content=None anymore.

  • In sendgrid package file named mail.py class Mail() they accept content kwargs but this package doesn't seems to send content when using Mail() in sgbackend/mail.py _build_sg_mail().

  • You can also find out the same issue raised here

The sample code in the readme makes Sendgrid send back a 400.

When I format the to address as directed in the readme I get a 400 back from Sendgrid.

mail = EmailMultiAlternatives(
  subject="Your Subject",
  body="This is a simple text email body.",
  from_email="Yamil Asusta <[email protected]>",
  to=["[email protected]"],
  headers={"Reply-To": "[email protected]"}
)
{
	"errors": [{
		"message": "Invalid type. Expected: string, given: array.",
		"field": "personalizations.0.to.0.email",
		"help": "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.personalizations.to"
	}]
}

conflict with sendgrid python v3.6.0

When I upgraded sendgrid python to version 3.6.0
my django project use sendgrid-django as email backend show such error:
'module' object has no attribute 'SendGridClient'
Then I uninstalled sendgrid python v3.6.0 and installed sendgrid python v1.4.0, sendgrid-django work again.

Unauthorized access issue?

Hi, I'm using a SendGrid API key I've verified has full access. However, sending requests with it is giving me HTTP 401 Unauthorized access. Can anyone help me out? Thanks
using: python 3.7.3

Django==3.0.7
sendgrid-django==4.2.0
sendgrid==3.6.3

settings.py:

SENDGRID_API_KEY = str.encode(os.getenv('SENDGRID_API_KEY'))
EMAIL_BACKEND = "sgbackend.SendGridBackend"

Can't set reply-to neither by header nor explicitly

By running README example:

mail = EmailMultiAlternatives(
  subject="Your Subject",
  body="This is a simple text email body.",
  from_email="[email protected]",
  to=["[email protected]"],
  headers={"Reply-To": "[email protected]"}
)
mail.send()

I get a 400 HTTP error

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.5/site-packages/django/core/mail/message.py", line 342, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python3.5/site-packages/sgbackend/mail.py", line 68, in send_messages
    self.sg.client.mail.send.post(request_body=mail)
  File "/usr/local/lib/python3.5/site-packages/python_http_client/client.py", line 204, in http_request
    return Response(self._make_request(opener, request))
  File "/usr/local/lib/python3.5/site-packages/python_http_client/client.py", line 138, in _make_request
    return opener.open(request)
  File "/usr/local/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.5/urllib/request.py", line 590, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

The thing is sendgrid-django has a set_reply_to method in the class Mail (https://github.com/sendgrid/sendgrid-python/blob/master/sendgrid/helpers/mail/mail.py#L154) while in sendgrid-django _build_sg_mail method (https://github.com/elbuo8/sendgrid-django/blob/master/sgbackend/mail.py#L69) reply_to is not added by the proper method, instead it expects to be added from setting a custom header like the example does:

for k, v in email.extra_headers.items():
    mail.add_header({k: v})

Next problem is django EmailMessage class only accepts reply_to param a list/tuple (https://github.com/django/django/blob/1c466994d9729a8902d34e277a3a685bef2a08e1/django/core/mail/message.py#L232) while sengrid-python expects only as I see one single email as reply-to (https://github.com/sendgrid/sendgrid-python/blob/master/sendgrid/helpers/mail/mail.py#L85 and https://github.com/sendgrid/sendgrid-python/blob/ca96c8dcd66224e13b38ab8fd2d2b429dd07dd02/examples/mail/mail.py#L132)

add fallback backend?

Would it make sense to add a SENDGRID_FALLBACK_EMAIL_BACKEND setting
so that if SendGrid fails to dispatch a message, a "spare" backend would be used?

For instance, when the daily quota runs out, some other backend would still send messages for the site.

I'll be happy to make a PR if this might be a good feature.

Upgrade to Sendgrid==1.4.0

Sendgrid added API key support after a fairly severe security breach. Their library is now at 1.4.0 and comes with api key support.

Please upgrade so we can stop using the arcane user / password method.

Incompatible with Python 3.5.2?

Just upgraded to 3.5.2 from 3.4.3 and I'm getting the following error when trying to send an email with an api key:

File "/usr/lib/python3.5/http/client.py", line 1083, in putheader
    raise ValueError('Invalid header value %r' % (values[i],))    
ValueError: Invalid header value b'Bearer <APIKEY>\r'

Error sending attachments with mimetype text/*

When sending a text attachment, Django will automatically try to convert from bytes to string (here, it's described in a docstring).

Unfortunately sendgrid-django is expecting bytes objects only (here)

To reproduce this you will need:

  • Python 3 (I'm using Python 3.6)
  • Add attachments using tuple with mimetype set to text/* where * is any string

Minimal code example (assuming sendgrid-django is configured):

from django.core.mail import EmailMessage

attachments = (
    ('file.txt', b'File content', 'text/plain'),
)
email = EmailMessage(
    subject='Email subject',
    body='Email body',
    from_email='[email protected]',
    to=('[email protected]', ),
    attachments=attachments,
)
email.send(fail_silently=False)  # <--- raises TypeError: a bytes-like object is required, not 'str'

From name is always empty

In previous versions, you could just do from_email="Company <[email protected]>".

However, as of 9cb2668, only the e-mail is passed to the new Email() method of the sendgrid package.

This means the From name is now always empty.

Possible to set send_at parameter?

Hi, thanks a lot for this cool integration!

However, is it possible to use sendgrids schedule mechanic? Using their smtp api you can specify a unix timestamp as "send_at", to delay the sending of a mail up to 3 days.

Would be awesome if anybody got any hints on how to do that with this package!

Best

Problem in version sendgrid-django==1.0.1

Hi, I received error when I tried to use last version

>>> from sgbackend.SendGridBackend import SendGridBackend
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File ".../python2.7/site-packages/sgbackend/__init__.py", line 1, in <module>
    from .mail import SendGridBackend
  File ".../python2.7/site-packages/sgbackend/mail.py", line 66
    raise Exception("CC list must be empty for SendGridHttpsBackEnd. CC not supported by the web API")
    ^
IndentationError: expected an indented block
>>>

Error after installing updated sendgrid-django package

I am getting an issue on my python 3.5 and Django 1.10 project. I uninstalled sendgrid and sendgrid-django from my list of packages, and then reinstalled sendgrid-django and I now get a HTTP Error 400: Bad Request error when I try to send mail.

When i check my packages it shows that sendgrid is now 3.6.3 and sendgrid-django is 4.0.1. Sendgrid used to be 1.4.0 and sendgrid-django was 2.0.0 It was working before I installed the new updated versions.

My code is this below
mail = EmailMultiAlternatives( subject="Your Subject", body="a new application was created!", from_email="[email protected] <[email protected]>", to=["[email protected]"], headers={"Reply-To": "[email protected]"} ) mail.send()

Ive been trying to figure out but cant see what is causing the error. I even went as far as clearing my virtual enviroment locally, and reinstalling my packages and that didnt work.

Mail.send() UnauthorizedError

I'm getting an UnauthorizedError when trying to send an email using this client. Anyone have any ideas where I should look?

SyntaxError on pip install [Python3]

Hi guys.

I just did a pip install and got this SyntaxError when building...

(env34)junkemen@junkemen-R480-R431-R481 ~/Documents/pinewoods/99contatores $ pip install sendgrid-django
Downloading/unpacking sendgrid-django
  Downloading sendgrid_django-4.0.4-py2.py3-none-any.whl
Downloading/unpacking sendgrid>=3.5,<4 (from sendgrid-django)
  Downloading sendgrid-3.6.3-py2.py3-none-any.whl
Downloading/unpacking python-http-client>=2.1.1 (from sendgrid>=3.5,<4->sendgrid-django)
  Downloading python_http_client-2.2.1-py2.py3-none-any.whl
Installing collected packages: sendgrid-django, sendgrid, python-http-client
*** Error compiling '/home/junkemen/Documents/pinewoods/99contatores/env34/build/sendgrid/sendgrid/temp.py'...
  File "/home/junkemen/Documents/pinewoods/99contatores/env34/build/sendgrid/sendgrid/temp.py", line 36
    print e.read()
          ^
SyntaxError: invalid syntax

Successfully installed sendgrid-django sendgrid python-http-client
Cleaning up...

Info about env

Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Django==1.9.7
sendgrid==3.6.3
sendgrid-django==4.0.4

Rendering images

Hi,

I'm using sendgrid-django along with the transactional templates.

I have linked images in the templates but when the email sends it only renders the link and no image.

Any thoughts?

HTTPError not being caught

I'm having issues with an HTTPError not being caught by SendgridBackend.send_messages. The error is python_http_client.exceptions.BadRequestsError: HTTP Error 400: Bad Request, from what I can see it should be caught if fail_silently = True(rather, it should not be rethrown), which is the case in my unittest.

Python: 3.6.0
Django: 1.10.7

Any ideas?

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.