Files
appointment_tool/src/mail/mail_sender.py
T

36 lines
1.1 KiB
Python

from mailjet_rest import Client
api_key = "489274f04d5c155f81370fccc3904e20"
api_secret = "edac41f0e1726ba49808dfb12204ecd6"
class MailSender:
def __init__(self, dest_email, email_body, store: str, contact_name: str, from_email="no-reply@lpaconsulting.fr"):
self.mailjet_client = Client(auth=(api_key, api_secret), version='v3.1')
self.store = store
self.from_email = from_email
self.dest_email = dest_email
self.contact_name = contact_name
self.email_body = email_body
def send(self):
data = {
'Messages': [
{
"From": {
"Email": self.from_email,
"Name": self.store
},
"To": [
{
"Email": self.dest_email,
"Name": self.contact_name
}
],
"Subject": "Your appointment is confirmed!",
"HTMLPart": self.email_body
}
]
}
return self.mailjet_client.send.create(data=data)