Created
February 24, 2024 15:12
-
-
Save Sofrosyn/4cf8ce984f0adc24a344bf5e4d3fa780 to your computer and use it in GitHub Desktop.
Invite brevo template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def invite(recipient_email, recipient_name, sender_name): | |
| # OTP Template id from brevo | |
| invite_template_id = 4 | |
| api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration)) | |
| # Specify recipient name, sent as subject of email | |
| subject = f"Hey {recipient_name}, join the world's leading academic minds at Unizonn!" | |
| # Unizonn Default senders email and name | |
| sender = {"name": "Unizonn", "email": "no-reply@unizonn.com"} | |
| # Specify users name and email, otp will be sent to the recipient email | |
| to = [{"email": recipient_email, "name": recipient_name}] | |
| # Header with API keys | |
| headers = { | |
| "api-key": API_KEY, #TODO -> Add BREVO_KEY | |
| "content-type": "application/json", | |
| "accept": " application/json" | |
| } | |
| # Specify user first name and pass otp here | |
| params = {"firstname": sender_name, "invite": recipient_name} | |
| send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(to=to, headers=headers, sender=sender, subject=subject, | |
| template_id=invite_template_id,params=params) | |
| try: | |
| api_response = api_instance.send_transac_email(send_smtp_email) | |
| pprint(api_response) | |
| except ApiException as e: | |
| print("Exception when calling SMTPApi->send_transac_email: %s\n" % e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment