Last active
December 15, 2023 13:47
-
-
Save rajshah001/075098dd98b9ca148e7dc3d5b2a4d49a to your computer and use it in GitHub Desktop.
Activation Email Sending Function
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
| import json | |
| import boto3 | |
| # Create a boto3 client for SES | |
| ses_client = boto3.client("ses") | |
| def lambda_handler(event, context): | |
| # Activation | |
| sender_email = "iambatmanbrucewayne6789@gmail.com" | |
| recipient_email = "rajshah.comps@gmail.com" | |
| subject = "Welcome to Bakery Shop" | |
| html_body = """ | |
| <!DOCTYPE html> | |
| <html lang="en" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml"> | |
| <head> | |
| <title></title> | |
| <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/> | |
| <meta content="width=device-width, initial-scale=1.0" name="viewport"/><!--[if mso]><xml><o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch><o:AllowPNG/></o:OfficeDocumentSettings></xml><![endif]--> | |
| <style> | |
| * { | |
| box-sizing: border-box; | |
| } | |
| body { | |
| margin: 0; | |
| padding: 0; | |
| } | |
| a[x-apple-data-detectors] { | |
| color: inherit !important; | |
| text-decoration: inherit !important; | |
| } | |
| #MessageViewBody a { | |
| color: inherit; | |
| text-decoration: none; | |
| } | |
| p { | |
| line-height: inherit | |
| } | |
| .desktop_hide, | |
| .desktop_hide table { | |
| mso-hide: all; | |
| display: none; | |
| max-height: 0px; | |
| overflow: hidden; | |
| } | |
| .image_block img+div { | |
| display: none; | |
| } | |
| @media (max-width:700px) { | |
| .desktop_hide table.icons-inner, | |
| .row-3 .column-1 .block-3.button_block .alignment a, | |
| .row-3 .column-1 .block-3.button_block .alignment div { | |
| display: inline-block !important; | |
| } | |
| .icons-inner { | |
| text-align: center; | |
| } | |
| .icons-inner td { | |
| margin: 0 auto; | |
| } | |
| .image_block div.fullWidth { | |
| max-width: 100% !important; | |
| } | |
| .mobile_hide { | |
| display: none; | |
| } | |
| .row-content { | |
| width: 100% !important; | |
| } | |
| .stack .column { | |
| width: 100%; | |
| display: block; | |
| } | |
| .mobile_hide { | |
| min-height: 0; | |
| max-height: 0; | |
| max-width: 0; | |
| overflow: hidden; | |
| font-size: 0px; | |
| } | |
| .desktop_hide, | |
| .desktop_hide table { | |
| display: table !important; | |
| max-height: none !important; | |
| } | |
| .row-1 .column-1 .block-1.paragraph_block td.pad>div { | |
| text-align: center !important; | |
| font-size: 18px !important; | |
| } | |
| .row-3 .column-1 .block-2.paragraph_block td.pad>div { | |
| text-align: left !important; | |
| font-size: 14px !important; | |
| } | |
| .row-3 .column-1 .block-1.heading_block h1, | |
| .row-3 .column-1 .block-3.button_block .alignment { | |
| text-align: left !important; | |
| } | |
| .row-3 .column-1 .block-1.heading_block h1 { | |
| font-size: 20px !important; | |
| } | |
| .row-4 .column-1 .block-1.icons_block .alignment { | |
| text-align: center !important; | |
| } | |
| .row-4 .column-1 .block-1.icons_block td.pad { | |
| padding: 10px 24px !important; | |
| } | |
| .row-3 .column-1 .block-3.button_block a, | |
| .row-3 .column-1 .block-3.button_block div, | |
| .row-3 .column-1 .block-3.button_block span { | |
| font-size: 14px !important; | |
| line-height: 28px !important; | |
| } | |
| .row-4 .column-2 .block-1.paragraph_block td.pad>div { | |
| text-align: left !important; | |
| font-size: 16px !important; | |
| } | |
| .row-3 .column-1 { | |
| padding: 0 24px 48px !important; | |
| } | |
| .row-4 .column-1 { | |
| padding: 16px 16px 8px !important; | |
| } | |
| .row-4 .column-2 { | |
| padding: 0 24px 16px !important; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body style="background-color: #f8f6ff; margin: 0; padding: 0; -webkit-text-size-adjust: none; text-size-adjust: none;"> | |
| <table border="0" cellpadding="0" cellspacing="0" class="nl-container" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f8f6ff; background-image: none; background-position: top left; background-size: auto; background-repeat: no-repeat;" width="100%"> | |
| <tbody> | |
| <tr> | |
| <td> | |
| <table align="center" border="0" cellpadding="0" cellspacing="0" class="row row-1" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;" width="100%"> | |
| <tbody> | |
| <tr> | |
| <td> | |
| <table align="center" border="0" cellpadding="0" cellspacing="0" class="row-content stack" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #a797ff; color: #000000; width: 680px; margin: 0 auto;" width="680"> | |
| <tbody> | |
| <tr> | |
| <td class="column column-1" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; padding-bottom: 32px; padding-left: 48px; padding-right: 48px; padding-top: 32px; vertical-align: top; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;" width="100%"> | |
| <table border="0" cellpadding="0" cellspacing="0" class="paragraph_block block-1" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;" width="100%"> | |
| <tr> | |
| <td class="pad"> | |
| <div style="color:#ffffff;direction:ltr;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:24px;font-weight:700;letter-spacing:0px;line-height:120%;text-align:left;mso-line-height-alt:28.799999999999997px;"> | |
| <p style="margin: 0;">Bakery Store</p> | |
| </div> | |
| </td> | |
| </tr> | |
| </table> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| <table align="center" border="0" cellpadding="0" cellspacing="0" class="row row-2" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;" width="100%"> | |
| <tbody> | |
| <tr> | |
| <td> | |
| <table align="center" border="0" cellpadding="0" cellspacing="0" class="row-content stack" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #a797ff; color: #000000; border-radius: 0; width: 680px; margin: 0 auto;" width="680"> | |
| <tbody> | |
| <tr> | |
| <td class="column column-1" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;" width="100%"> | |
| <table border="0" cellpadding="0" cellspacing="0" class="image_block block-1" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;" width="100%"> | |
| <tr> | |
| <td class="pad" style="width:100%;padding-right:0px;padding-left:0px;"> | |
| <div align="center" class="alignment" style="line-height:10px"> | |
| <div class="fullWidth" style="max-width: 640px;"><img alt="An open email illustration" src="https://i.postimg.cc/Kjjv9qk8/Email-Illustration.png" style="display: block; height: auto; border: 0; width: 100%;" title="An open email illustration" width="640"/></div> | |
| </div> | |
| </td> | |
| </tr> | |
| </table> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| <table align="center" border="0" cellpadding="0" cellspacing="0" class="row row-3" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;" width="100%"> | |
| <tbody> | |
| <tr> | |
| <td> | |
| <table align="center" border="0" cellpadding="0" cellspacing="0" class="row-content stack" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 680px; margin: 0 auto;" width="680"> | |
| <tbody> | |
| <tr> | |
| <td class="column column-1" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; padding-bottom: 48px; padding-left: 48px; padding-right: 48px; vertical-align: top; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;" width="100%"> | |
| <table border="0" cellpadding="0" cellspacing="0" class="heading_block block-1" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;" width="100%"> | |
| <tr> | |
| <td class="pad" style="padding-top:12px;text-align:center;width:100%;"> | |
| <h1 style="margin: 0; color: #292929; direction: ltr; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 32px; font-weight: 700; letter-spacing: normal; line-height: 120%; text-align: left; margin-top: 0; margin-bottom: 0; mso-line-height-alt: 38.4px;"><span class="tinyMce-placeholder">Welcome To Bakery Store!</span></h1> | |
| </td> | |
| </tr> | |
| </table> | |
| <table border="0" cellpadding="0" cellspacing="0" class="paragraph_block block-2" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;" width="100%"> | |
| <tr> | |
| <td class="pad" style="padding-bottom:10px;padding-top:10px;"> | |
| <div style="color:#101112;direction:ltr;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:120%;text-align:left;mso-line-height-alt:19.2px;"> | |
| <p style="margin: 0;">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <br/><br/>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p> | |
| </div> | |
| </td> | |
| </tr> | |
| </table> | |
| <table border="0" cellpadding="0" cellspacing="0" class="button_block block-3" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;" width="100%"> | |
| <tr> | |
| <td class="pad" style="padding-top:24px;text-align:left;"> | |
| <div align="left" class="alignment"><!--[if mso]> | |
| <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://www.example.com/" style="height:48px;width:177px;v-text-anchor:middle;" arcsize="17%" stroke="false" fillcolor="#7259ff"> | |
| <w:anchorlock/> | |
| <v:textbox inset="0px,0px,0px,0px"> | |
| <center style="color:#ffffff; font-family:Arial, sans-serif; font-size:16px"> | |
| <![endif]--><a href="http://www.example.com/" style="text-decoration:none;display:inline-block;color:#ffffff;background-color:#7259ff;border-radius:8px;width:auto;border-top:0px solid transparent;font-weight:400;border-right:0px solid transparent;border-bottom:0px solid transparent;border-left:0px solid transparent;padding-top:8px;padding-bottom:8px;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;text-align:center;mso-border-alt:none;word-break:keep-all;" target="_blank"><span style="padding-left:16px;padding-right:16px;font-size:16px;display:inline-block;letter-spacing:normal;"><span style="word-break: break-word; line-height: 32px;">Confirm subscription</span></span></a><!--[if mso]></center></v:textbox></v:roundrect><![endif]--></div> | |
| </td> | |
| </tr> | |
| </table> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| <table align="center" border="0" cellpadding="0" cellspacing="0" class="row row-4" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;" width="100%"> | |
| <tbody> | |
| <tr> | |
| <td> | |
| <table align="center" border="0" cellpadding="0" cellspacing="0" class="row-content stack" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #e8e4ff; border-bottom: 0 solid #FFFFFF; border-left: 20px solid #FFFFFF; border-radius: 0; border-right: 20px solid #FFFFFF; border-top: 0 solid #FFFFFF; color: #000000; width: 680px; margin: 0 auto;" width="680"> | |
| <tbody> | |
| <tr> | |
| <td class="column column-1" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; padding-bottom: 24px; padding-left: 8px; padding-right: 8px; padding-top: 24px; vertical-align: middle; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;" width="16.666666666666668%"> | |
| <table border="0" cellpadding="0" cellspacing="0" class="icons_block block-1" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;" width="100%"> | |
| <tr> | |
| <td class="pad" style="vertical-align: middle; color: #000000; font-family: inherit; font-size: 14px; font-weight: 400; text-align: center;"> | |
| <table align="center" cellpadding="0" cellspacing="0" class="alignment" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;"> | |
| <tr> | |
| <td style="vertical-align: middle; text-align: center; padding-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px;"><img align="center" class="icon" height="32" src="https://i.postimg.cc/1R7zgQ2n/Gift-Emoji.png" style="display: block; height: auto; margin: 0 auto; border: 0;" width="34"/></td> | |
| </tr> | |
| </table> | |
| </td> | |
| </tr> | |
| </table> | |
| </td> | |
| <td class="column column-2" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; padding-bottom: 5px; padding-right: 48px; padding-top: 5px; vertical-align: middle; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;" width="83.33333333333333%"> | |
| <table border="0" cellpadding="0" cellspacing="0" class="paragraph_block block-1" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;" width="100%"> | |
| <tr> | |
| <td class="pad"> | |
| <div style="color:#7860ff;direction:ltr;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:150%;text-align:left;mso-line-height-alt:24px;"> | |
| <p style="margin: 0;"><u></u><a href="https://google.com" rel="noopener" style="text-decoration: underline; color: #3e2d9c;" target="_blank"><u><strong>Learn More About Cookies</strong></u></a></p> | |
| </div> | |
| </td> | |
| </tr> | |
| </table> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table><!-- End --> | |
| </body> | |
| </html> | |
| """ | |
| # Define the message structure | |
| message = { | |
| "Subject": {"Data": subject, "Charset": "UTF-8"}, | |
| "Body": {"Html": {"Data": html_body, "Charset": "UTF-8"}}, | |
| } | |
| # Send the email | |
| ses_client.send_email( | |
| Source=sender_email, | |
| Destination={"ToAddresses": [recipient_email]}, | |
| Message=message, | |
| ConfigurationSetName="offer-config-set", | |
| Tags=[ | |
| {"Name": "Interest", "Value": "Cookies"}, | |
| ], | |
| ) | |
| print(f"Sent HTML email to {recipient_email} with subject: {subject}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment