Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 736 Bytes

README.md

File metadata and controls

35 lines (27 loc) · 736 Bytes

nameko-sendgrid

SendGrid dependency for nameko services

Installation

pip install nameko-sendgrid

Usage

from nameko.rpc import rpc
from nameko_sendgrid import SendGrid
from sendgrid.helpers.mail import *


class Service:
    name = "service"
    
    sendgrid = SendGrid()
    
    @rpc
    def send_email(self, address, body):
        from_email = Email("test@example.com")
        to_email = Email(address)
        subject = "Sending with SendGrid is Fun"
        content = Content("text/plain", body)
        message = Mail(from_email, subject, to_email, content)
        
        self.sendgrid.client.mail.send.post(message)

Specify your configuration like this:

SENDGRID_KEY: abcd