Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sendgrid
- class Email(object):
- def __init__(self, api_key):
- self.sg = sendgrid.SendGridAPIClient(apikey=api_key)
- self.from_name = 'from name'
- def send(self, to_email, from_email, subj, msg, category, time=-1):
- data = {
- "personalizations": [
- {
- "to": [
- {
- "email": str(to_email)
- }
- ]
- }
- ],
- "content": [
- {
- "type": "text/html",
- "value": str(msg)
- }
- ],
- "from": {
- "email": from_email,
- "name": self.from_name
- },
- "subject": str(subj),
- "categories": [category]
- }
- data['send_at'] = int(time)
- response = self.sg.client.mail.send.post(request_body=data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement