April 3, 2021, 1:27 p.m.
Sending emails through programming languages like python has many use cases.
For example, you might want to send transactional emails.
Sending emails through programming languages like python has many use cases.
For example, you might want to send transactional emails.
You can send email using mailjet API.
1) Go to mailjet.com
2) Create an account
3) Get your API KEY & SECRET KEY
Authentication Required:
All Email API endpoints requests are authenticated using HTTPS Basic Auth. It requires you to provide a username and a password for each API request.
The username is your API Key and the password is your API Secret Key - you can find them in your API Key Management page. Both keys are generated automatically when your account is created.
To send an email, you need the following mandatory properties:
FromEmail: a verified Sender address
Recipients: list with at least one Email address
Text-part and/or Html-part: content of the message sent in text or HTML format. At least one of these content type needs to be specified. When Html-part is the only content provided, Mailjet will not generate a Text-part from the HTML version.
from mailjet_rest import Client
import os
api_key = os.environ['API KEY']
api_secret = os.environ['SECRET KEY']
mailjet = Client(auth=(api_key, api_secret))
data = {
'FromEmail': 'pilot@mailjet.com',
'FromName': 'Mailjet Pilot',
'Subject': 'Your email flight plan!',
'Text-part': 'Dear passenger, welcome to Mailjet! May the delivery force be with you!',
'Html-part': '<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!',
'Recipients': [{'Email':'passenger@mailjet.com'}]
}
result = mailjet.send.create(data=data)
print result.status_code
print result.json()
You simply send email to any user using this API you can also check stats of your email.
Can check status of your email:
Delivered
Failed
Opened etc.
You can use templates or can create according to your need using mailjet templates and can pass the variable from your site.
You can send 200 email daily free of cost. If your need more you can opt for the plan according to your needs.