{"action":"created","issue":{"url":"https://api.github.com/repos/elbuo8/sendgrid-django/issues/15","repository_url":"https://api.github.com/repos/elbuo8/sendgrid-django","labels_url":"https://api.github.com/repos/elbuo8/sendgrid-django/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/elbuo8/sendgrid-django/issues/15/comments","events_url":"https://api.github.com/repos/elbuo8/sendgrid-django/issues/15/events","html_url":"https://github.com/elbuo8/sendgrid-django/issues/15","id":114915976,"number":15,"title":"Sending emails with attachements does not work well when using this library","user":{"login":"poojasgada","id":1909479,"avatar_url":"https://avatars.githubusercontent.com/u/1909479?v=3","gravatar_id":"","url":"https://api.github.com/users/poojasgada","html_url":"https://github.com/poojasgada","followers_url":"https://api.github.com/users/poojasgada/followers","following_url":"https://api.github.com/users/poojasgada/following{/other_user}","gists_url":"https://api.github.com/users/poojasgada/gists{/gist_id}","starred_url":"https://api.github.com/users/poojasgada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poojasgada/subscriptions","organizations_url":"https://api.github.com/users/poojasgada/orgs","repos_url":"https://api.github.com/users/poojasgada/repos","events_url":"https://api.github.com/users/poojasgada/events{/privacy}","received_events_url":"https://api.github.com/users/poojasgada/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2015-11-03T21:35:53Z","updated_at":"2016-10-21T10:12:55Z","closed_at":null,"body":"Hi, \r\n\r\nI 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.\r\n\r\nHere's a snippet of my django code which is sending out HTML emails with attachements:\r\n\r\n```\r\n# To attach the image inline.\r\n  msg = EmailMultiAlternatives(subject, text_content, from_email, to_email)\r\n  msg.attach_alternative(html_content, \"text/html\")\r\n  msg.mixed_subtype = 'related'\r\n\r\n  fp = open(IMAGE_PATH+ imgName, 'rb')\r\n  msg_img = MIMEImage(fp.read(), name=imgName)\r\n  fp.close()\r\n  msg_img.add_header('Content-ID', '<{0}>'.format(imgName))\r\n  msg.attach(msg_img)\r\n```\r\n\r\nAnd then i use send_messages() to send out these messages. \r\n\r\nIn the email that gets sent out, the attachments seem to be malformed. Am i missing something ?\r\n\r\nAppreciate your help. "},"comment":{"url":"https://api.github.com/repos/elbuo8/sendgrid-django/issues/comments/255345139","html_url":"https://github.com/elbuo8/sendgrid-django/issues/15#issuecomment-255345139","issue_url":"https://api.github.com/repos/elbuo8/sendgrid-django/issues/15","id":255345139,"user":{"login":"andriisoldatenko","id":1374633,"avatar_url":"https://avatars.githubusercontent.com/u/1374633?v=3","gravatar_id":"","url":"https://api.github.com/users/andriisoldatenko","html_url":"https://github.com/andriisoldatenko","followers_url":"https://api.github.com/users/andriisoldatenko/followers","following_url":"https://api.github.com/users/andriisoldatenko/following{/other_user}","gists_url":"https://api.github.com/users/andriisoldatenko/gists{/gist_id}","starred_url":"https://api.github.com/users/andriisoldatenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andriisoldatenko/subscriptions","organizations_url":"https://api.github.com/users/andriisoldatenko/orgs","repos_url":"https://api.github.com/users/andriisoldatenko/repos","events_url":"https://api.github.com/users/andriisoldatenko/events{/privacy}","received_events_url":"https://api.github.com/users/andriisoldatenko/received_events","type":"User","site_admin":false},"created_at":"2016-10-21T10:12:55Z","updated_at":"2016-10-21T10:12:55Z","body":"For Python3 working example:\r\n```\r\nfrom django.core.mail import EmailMultiAlternatives\r\n\r\nmail = EmailMultiAlternatives(\r\n        subject=subject,\r\n        body=body,\r\n        from_email=from_email,\r\n        to=[to_email]\r\n    )\r\nfile = open('somefilename.pdf', 'rb').read()\r\nmail.attachments = [('full_report.pdf', file, 'application/pdf')]\r\nmail.send()\r\n```\r\nFor more details:\r\nhttps://github.com/elbuo8/sendgrid-django/blob/master/sgbackend/mail.py#L96-L111"}}
{"actor":{"display_login":"andriisoldatenko"}}