Ejemplo n.º 1
0
def initialize_api_instance_transactional(*args, **kwargs):
    # Configure API key authorization: api-key
    configuration = sib_api_v3_sdk.Configuration()
    configuration.api_key['api-key'] = SEND_IN_BLUE_API_KEY

    # create an instance of the API class
    api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration))
    bcc = kwargs.get('bcc', None)
    if bcc == '':
        bcc = None
    cc = kwargs.get('cc', None)
    if cc == '':
        cc = None
    reply_to = kwargs.get('reply_to', None)
    if reply_to == '':
        reply_to = None
    send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(
        attachment=None,
        bcc=bcc,
        cc=cc,
        headers=kwargs.get('headers', None),
        html_content=kwargs.get('body', None),
        message_versions=None,
        params=None,
        reply_to=reply_to,
        sender=kwargs.get('sender', DEFAULT_EMAIL_SENDER),
        subject=kwargs.get('title', None),
        tags=None,
        template_id=None,
        text_content=None,
        to=kwargs.get('to', None)
    )
    return api_instance, send_smtp_email
def send_transactional_email(payload: SendTransactionalEmailRequest) -> bool:
    to = [{"email": email} for email in payload.recipients]
    sender = {"email": settings.SUPPORT_EMAIL_ADDRESS, "name": "pass Culture"}
    template_id = payload.template_id
    params = payload.params
    tags = payload.tags

    configuration = sib_api_v3_sdk.Configuration()
    configuration.api_key["api-key"] = settings.SENDINBLUE_API_KEY
    api_instance = sib_api_v3_sdk.TransactionalEmailsApi(
        sib_api_v3_sdk.ApiClient(configuration))

    send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(to=to,
                                                   sender=sender,
                                                   reply_to=sender,
                                                   template_id=template_id,
                                                   params=params,
                                                   tags=tags)

    try:
        api_instance.send_transac_email(send_smtp_email)
        return True
    except ApiException as e:
        logger.error(
            "Exception when calling SMTPApi->send_transac_email: %s\n", e)
        return False
    except Exception as e:  # pylint: disable=broad-except
        logger.error(
            "Unknown exception occurred when calling SMTPApi->send_transac_email: %s\n",
            e)
        return False
Ejemplo n.º 3
0
def sendInBlueEmail(params):
    configuration = sib_api_v3_sdk.Configuration()

    configuration.api_key['api-key'] = os.environ.get(
        "SEND_IN_BLUE"
    )  ## Either pass your key directly here or add in the aws console of lambda function
    api_instance = sib_api_v3_sdk.TransactionalEmailsApi(
        sib_api_v3_sdk.ApiClient(configuration))
    subject = "from the Python SDK!"
    sender = {"name": "sample", "email": "*****@*****.**"}
    replyTo = {"name": "sample", "email": "*****@*****.**"}
    html_content = "<html><body><h1>Find Vaccine Availability in navi mumbai </h1></body></html>"
    to = to_addresses
    send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(bcc=cc_addresses,
                                                   to=to_addresses,
                                                   reply_to=replyTo,
                                                   template_id=1,
                                                   sender=sender,
                                                   subject=subject,
                                                   params=params)

    try:
        api_response = api_instance.send_transac_email(send_smtp_email)
        print(api_response)
    except ApiException as e:
        print("Exception when calling SMTPApi->send_transac_email: %s\n" % e)
Ejemplo n.º 4
0
def send_email():

    api_instance = sib_api_v3_sdk.TransactionalEmailsApi(
        sib_api_v3_sdk.ApiClient(configuration))

    email = {
        "to": ['*****@*****.**'],
        "reply_to": '*****@*****.**',
        "sender": {
            "name": 'Testing UWCC',
            "email": '*****@*****.**'
        },
        "html_content":
        'This test was successful, \nthanks for participating!',
        "subject": 'Test'
    }

    send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(**email)

    try:
        api_response = api_instance.send_transac_email(send_smtp_email)
        print(api_response)
    except ApiException as e:
        print("Exception when calling SMTPApi->send_transac_email: %s\n" % e)
        raise e
Ejemplo n.º 5
0
def booking():
    if request.method == 'POST':
        uname = request.form.get('name')
        email = request.form.get('email')
        contact = request.form.get('contact')
        skypeID = request.form.get('skypeID')
        date = request.form.get('date')
        timeslot = request.form.get('timeslot')
        result = timeslotBooking.find({}).count() + 1
        uid = "B-WSS" + "%07d" % result
        name = uname.split()[0]
        configuration = sib_api_v3_sdk.Configuration()
        configuration.api_key[
            'api-key'] = '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'
        api_instance = sib_api_v3_sdk.SMTPApi(
            sib_api_v3_sdk.ApiClient(configuration))
        send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(
            to=[{
                "email": email,
                "name": name
            }],
            template_id=15,
            params={
                "name": name,
                "date": date,
                "time": timeslot
            },
            headers={
                "X-Mailin-custom":
                "custom_header_1:custom_value_1|custom_header_2:custom_value_2|custom_header_3:custom_value_3",
                "charset": "iso-8859-1"
            })  # SendSmtpEmail | Values to send a transactional email
        try:
            # Send a transactional email
            api_response = api_instance.send_transac_email(send_smtp_email)
            timeslotBooking.insert_one({
                "_id": uid,
                "Name": name,
                "Email": email,
                "Contact": contact,
                "SkypeID": skypeID,
                "Date": date,
                "TimeSlot": timeslot
            })
            pprint(api_response)
            return jsonify({
                "Name": name,
                "Email": email,
                "Contact Number": contact,
                "SkypeID": skypeID,
                "Date": date,
                "TimeSlot": timeslot
            })
        except ApiException as e:
            print("Exception when calling SMTPApi->send_transac_email: %s\n" %
                  e)

    return render_template('booking.html')
Ejemplo n.º 6
0
def send_new_message_email(from_email, from_name, to_email, to_name, link):
    mail = sib_sdk.SendSmtpEmail(
        sender={"name": "Studio Rubik", "email": "*****@*****.**"},
        to=[{"name": to_name, "email": to_email}],
        template_id=2,
        params={"from_name": from_name, "to_name": to_name, "link": link},
    )
    try:
        smtp.send_transac_email(mail)
    except ApiException as e:
        print(e)
def send_email(emailid, content):
    api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration))
    send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(to=emailid, subject="Slot available by Laksh", params={"CONTENT": content},template_id=5, headers={"X-Mailin-custom": "custom_header_1:custom_value_1|custom_header_2:custom_value_2|custom_header_3:custom_value_3", "charset": "iso-8859-1"}) # SendSmtpEmail | Values to send a transactional email
    try:
        api_response = api_instance.send_transac_email(send_smtp_email)
        print(f"Sent email to: {emailid}")
        print(api_response)
        return True
    except ApiException as e:
        print("Exception when calling SMTPApi->send_transac_email: %s\n" % e)
        return False
Ejemplo n.º 8
0
 def check():
     characters = string.ascii_letters + string.digits
     password = "".join(
         choice(characters) for x in range(randint(8, 8)))
     if re.search("[0-9][a-z][A-Z]", password):
         global pd
         pd = password
         configuration = sib_api_v3_sdk.Configuration()
         configuration.api_key[
             'api-key'] = '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'
         api_instance = sib_api_v3_sdk.SMTPApi(
             sib_api_v3_sdk.ApiClient(configuration))
         send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(
             to=[{
                 "email": email,
                 "name": name
             }],
             template_id=14,
             params={
                 "name": name,
                 "email": email,
                 "pwd": password
             },
             headers={
                 "X-Mailin-custom":
                 "custom_header_1:custom_value_1|custom_header_2:custom_value_2|custom_header_3:custom_value_3",
                 "charset": "iso-8859-1"
             }
         )  # SendSmtpEmail | Values to send a transactional email
         try:
             # Send a transactional email
             api_response = api_instance.send_transac_email(
                 send_smtp_email)
             user.insert_one({
                 "_id": uid,
                 "Name": name,
                 "Email": email,
                 "Password": pd
             })
             User_delete.remove({"Email": email}, {
                 "Name": 1,
                 "Email": 1,
                 "Password": 1,
                 "_id": 1
             })
             pprint(api_response)
         except ApiException as e:
             print(
                 "Exception when calling SMTPApi->send_transac_email: %s\n"
                 % e)
         #
     else:
         return check()
Ejemplo n.º 9
0
 def use_api_email(self, missive):
     api_instance = self.api_email
     send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(
         to=[{"email": self.missive.target}],
         reply_to={"email": conf.reply_email, "name": conf.reply_name},
         sender={"email": conf.sender_email, "name": conf.sender_name},
         subject= self.missive.subject
         html_content=self.missive.html,
         text_content=self.missive.txt,
     )
     try:
         api_response = api_instance.send_transac_email(send_smtp_email)
         self.missive.trace = str(api_response)
         return True
     except Exception as e:
         self.missive.trace(str(e))
         return False
Ejemplo n.º 10
0
def send_email(to_emails,
               title,
               body,
               from_email=None,
               from_name=None,
               receiver_names=None):

    api_instance = sib_api_v3_sdk.TransactionalEmailsApi(
        sib_api_v3_sdk.ApiClient(configuration))

    # Prepare the list of recipients, optionally including names
    if receiver_names is None:
        recipients = [{'email': mail} for mail in to_emails]
    else:
        recipients = [{
            'email': mail,
            'name': name
        } for name, mail in zip(receiver_names, to_emails)]

    email = {
        "to": recipients,
        "reply_to": {
            'email': from_email
        },
        "sender": {
            "name": from_name,
            "email": from_email
        },
        "html_content": body,
        "subject": title
    }

    send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(**email)

    try:
        api_response = api_instance.send_transac_email(send_smtp_email)
        print(api_response)
    except ApiException as e:
        print("Exception when calling SMTPApi->send_transac_email: %s\n" % e)
        raise e
Ejemplo n.º 11
0
 def perform(self, message: Msg, sender: str, lang: str, **kwargs):
     title_html, body_html, attachments = self.render(message, lang)
     api_instance = sib_api_v3_sdk.SMTPApi(sib_api_v3_sdk.ApiClient(self.configuration))
     senderSmtp = sib_api_v3_sdk.SendSmtpEmailSender(
         name=self.sender_name,
         email=self.sender_email,
     )
     sendTo = sib_api_v3_sdk.SendSmtpEmailTo(
         email=message.recipient,
         name="Recipient Name"  # what's the name?
     )
     arrTo = [sendTo]
     sending_kwargs = {
         "sender": senderSmtp,
         "to": arrTo,
         "html_content": body_html,
         "subject": title_html,
     }
     # attachments.append(self.get_logo_attachment())
     if attachments:
         sending_kwargs['attachment'] = attachments
     send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(**sending_kwargs)
     api_response = api_instance.send_transac_email(send_smtp_email)
     return api_response
Ejemplo n.º 12
0
    def envio_email(self, correo, nombre, apellido, total, productos):

        configuration = sib_api_v3_sdk.Configuration()
        configuration.api_key[
            'api-key'] = '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'
        fecha = datetime.now()
        dia = fecha.day
        mes = fecha.month
        anio = fecha.year
        fecha_compra = str(dia) + "/" + str(mes) + "/" + str(anio)
        # cra un instancia de la Api

        api_instance = sib_api_v3_sdk.TransactionalEmailsApi(
            sib_api_v3_sdk.ApiClient(configuration))
        send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(to=[{
            "email": correo,
            "name": nombre
        }],
                                                       template_id=2,
                                                       params={
                                                           "DATE":
                                                           fecha_compra,
                                                           "NOMBRE": nombre,
                                                           "APELLIDO":
                                                           apellido,
                                                           "TOTAL": total,
                                                           "PRODUCTOS":
                                                           productos
                                                       })

        try:
            # Envio de email transaccional
            api_response = api_instance.send_transac_email(send_smtp_email)
            pprint(api_response)
        except ApiException as e:
            print("Error al envio: %s\n" % e)
Ejemplo n.º 13
0
    def send_campaign(self, request, campaign, contacts, test_send=False):

        sib_api_key = getattr(settings, "SENDINBLUE_API_KEY", None)
        config = None
        if sib_api_key:
            config = sib_api_v3_sdk.Configuration()
            config.api_key['api-key'] = sib_api_key
        else:
            logging.info("No SIB mailing list")

        if test_send and config:
            for contact in contacts:
                content = render_to_string(
                    campaign.get_template(request),
                    campaign.get_context(request, contact),
                )
                # create an instance of the API class
                api_instance = sib_api_v3_sdk.TransactionalEmailsApi(
                    sib_api_v3_sdk.ApiClient(config))
                send_smtp_email_sender = sib_api_v3_sdk.SendSmtpEmailSender(
                    email=self.from_email)
                send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(
                    sender=send_smtp_email_sender,
                    to=[{
                        'email': contact.email
                    }],
                    html_content=content,
                    subject=campaign.subject,
                    headers={
                        "X-Mailin-custom":
                        "custom_header_1:custom_value_1|custom_header_2:custom_value_2|custom_header_3:custom_value_3",
                        "charset": "iso-8859-1"
                    })

                try:
                    # Send a transactional email
                    api_response = api_instance.send_transac_email(
                        send_smtp_email)
                except ApiException as e:
                    messages.error(request, f"Test email failed: {e}")
                    print(
                        "Exception when calling SMTPApi->send_transac_email: %s\n"
                        % e)

        elif sib_api_key:
            # To satisfy module internals we need a dummy email address as the contact in the content
            api_instance = sib_api_v3_sdk.ContactsApi(
                sib_api_v3_sdk.ApiClient(config))
            lists = api_instance.get_lists(limit=50).lists
            lists = list(
                filter(lambda l: campaign.mailing_lists in l['name'], lists))
            contact = re.sub('\s+', '',
                             campaign.mailing_lists) + "@climate.esa.int"

            content = render_to_string(campaign.get_template(request),
                                       campaign.get_context(request, contact))

            sendTime = datetime.utcnow() + timedelta(minutes=5)
            sendTimeStr = sendTime.strftime("%Y-%m-%dT%H:%M:%S.000Z")

            selected_lists = [l['id'] for l in lists]
            url = "https://api.sendinblue.com/v3/emailCampaigns"

            payload = {
                "sender": {
                    "email": self.from_email
                },
                "recipients": {
                    "listIds": selected_lists
                },
                "inlineImageActivation": False,
                "sendAtBestTime": False,
                "abTesting": False,
                "ipWarmupEnable": False,
                "name": campaign.name,
                "htmlContent": content,
                "subject": campaign.subject,
                "scheduledAt": sendTimeStr
            }
            headers = {
                "Accept": "application/json",
                "Content-Type": "application/json",
                "api-key": sib_api_key
            }

            the_campaign = SendCampaign(request, campaign.pk, url, payload,
                                        headers)
            the_campaign.run()
Ejemplo n.º 14
0
from pprint import pprint

configuration = sib_api_v3_sdk.Configuration()
configuration.api_key['api-key'] = 'YOUR API KEY'

api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration))
subject = "My Subject"
html_content = "<html><body><h1>This is my first transactional email </h1></body></html>"
sender = {"name":"John Doe","email":"*****@*****.**"}
to = [{"email":"*****@*****.**","name":"Jane Doe"}]
cc = [{"email":"*****@*****.**","name":"Janice Doe"}]
bcc = [{"name":"John Doe","email":"*****@*****.**"}]
reply_to = {"email":"*****@*****.**","name":"John Doe"}
headers = {"Some-Custom-Name":"unique-id-1234"}
params = {"parameter":"My param value","subject":"New Subject"}
send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(to=to, bcc=bcc, cc=cc, reply_to=reply_to, headers=headers, html_content=html_content, sender=sender, subject=subject)

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)

class MissiveBackend(MissiveBackend):
    CONFSIB = False
    APISIB = False
    APIEMAIL = False

    @property
    def conf_sib(self):
        if not self.CONFSIB:
Ejemplo n.º 15
0
    def send_reset_email(cls, user, url):
        configuration = sib_api_v3_sdk.Configuration()
        configuration.api_key['api-key'] = os.getenv('API_KEY')

        api_instance = sib_api_v3_sdk.TransactionalEmailsApi(
            sib_api_v3_sdk.ApiClient(configuration))
        subject = "Password Reset Request for LISA"

        html_content = """
        <!DOCTYPE html>
        <html>

        <head>
            <!-- Remote style sheet -->
            <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">

        </head>

        <body style="background-color:#f9f9f9;">
            <div class= "container" style="background-color:#f9f9f9;width:500px;border-collapse:collapse;border-spacing:0;position:absolute;margin-left:auto;margin-right:auto;left:0;right:0;">
                <img src="https://firebasestorage.googleapis.com/v0/b/projectdoc-5af7b.appspot.com/o/template%2Fwp2570965.jpg?alt=media&token=678c9c38-92da-4ba1-ad89-32a461871e9e" style="height:auto;display:block;display: block;margin-left: auto;margin-right: auto;width: 100%;" </img>
                <table role="presentation" style="background-color:#ffffff;border: 1px solid #c5cad9;">
                    <tr>
                        <td style="text-align:center;vertical-align:top;direction:ltr;font-size:0px;padding:40px 50px">
                            <div aria-labelledby="mj-column-per-100" class="m_6964446768198031751mj-column-per-100"
                                style="vertical-align:top;display:inline-block;direction:ltr;font-size:13px;text-align:left;width:100%">
                                <table role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
                                    <tbody>
                                        <tr>
                                            <td style="word-break:break-word;font-size:0px;padding:0px" align="left">
                                                <div
                                                    style="color:#737f8d;font-family:Whitney,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px;line-height:24px;text-align:left">

                                                    <h2
                                                        style="font-family:Whitney,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-weight:500;font-size:20px;color:#4f545c;letter-spacing:0.27px">
                                                        Hey {},</h2>
                                                    <p>Your LISA password can be <span class="il">reset</span> by clicking
                                                        the button below. If you did not request a new password, please ignore
                                                        this email.</p>

                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="word-break:break-word;font-size:0px;padding:10px 25px;padding-top:20px"
                                                align="center">
                                                <table role="presentation" cellpadding="0" cellspacing="0"
                                                    style="border-collapse:separate" align="center" border="0">
                                                    <tbody>
                                                        <tr>
                                                            <td style="border:none;border-radius:3px;color:white;padding:15px 19px"
                                                                align="center" valign="middle" bgcolor="#7289DA"><a
                                                                    href={}
                                                                    style="text-decoration:none;line-height:100%;background:#7289da;color:white;font-family:Ubuntu,Helvetica,Arial,sans-serif;font-size:15px;font-weight:normal;text-transform:none;margin:0px"
                                                                    <span class="il">Reset</span> Password
                                                                </a></td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="word-break:break-word;font-size:0px;padding:30px 0px">
                                                <p
                                                    style="font-size:1px;margin:0px auto;border-top:1px solid #dcddde;width:100%">
                                                </p>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="word-break:break-word;font-size:0px;padding:0px" align="left">
                                                <!-- <div
                                                    style="color:#747f8d;font-family:Whitney,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:13px;line-height:16px;text-align:left">
                                                    <p>Need help? <a
                                                            href="https://url9624.discordapp.com/ls/click?upn=qDOo8cnwIoKzt0aLL1cBeNlOcN7VC1Mue2BSa5oqYEdKm-2BPBEvWHLEUfi61TfqfxuvBipSaAkPtkAVPOEnBIzw-3D-3DioHW_av9jLgVz1hP-2FL23lkyqaU7Iw5z8d9cjUxeAc64zG-2BCrkrwGzXJ0UvMvbPbh0CuPQR4XvzIFXgeoDwXnAKuYf1dtVLmy9bjZvmioy7CiEqaaUw0gzmeeN8hENSyy-2BFnnQe-2Bt0mXQLXh3CpZv7j24L7dUFCGxoOSGlsSi-2B4h5FzeuZMsnKz6Jpe5b264knMhKDgyD4eh8tObF3gzgwNSZy4OPjH7x6In-2B1V3zD3HFxLZI-3D"
                                                            style="font-family:Whitney,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;color:#7289da"
                                                            target="_blank"
                                                            data-saferedirecturl="https://www.google.com/url?q=https://url9624.discordapp.com/ls/click?upn%3DqDOo8cnwIoKzt0aLL1cBeNlOcN7VC1Mue2BSa5oqYEdKm-2BPBEvWHLEUfi61TfqfxuvBipSaAkPtkAVPOEnBIzw-3D-3DioHW_av9jLgVz1hP-2FL23lkyqaU7Iw5z8d9cjUxeAc64zG-2BCrkrwGzXJ0UvMvbPbh0CuPQR4XvzIFXgeoDwXnAKuYf1dtVLmy9bjZvmioy7CiEqaaUw0gzmeeN8hENSyy-2BFnnQe-2Bt0mXQLXh3CpZv7j24L7dUFCGxoOSGlsSi-2B4h5FzeuZMsnKz6Jpe5b264knMhKDgyD4eh8tObF3gzgwNSZy4OPjH7x6In-2B1V3zD3HFxLZI-3D&amp;source=gmail&amp;ust=1623380898827000&amp;usg=AFQjCNGTsQC5Fqab-gw8xvqCTjY7INY4eA">Contact
                                                            our support team</a> or hit us up on Twitter <a
                                                            href="https://url9624.discordapp.com/ls/click?upn=qDOo8cnwIoKzt0aLL1cBeHLasbud5D3vi74o1Q-2B2VLcLLCDOodJpEqop-2Fc-2F5Wr6ZjdI4_av9jLgVz1hP-2FL23lkyqaU7Iw5z8d9cjUxeAc64zG-2BCrkrwGzXJ0UvMvbPbh0CuPQmfNZNY-2FILyobSO4P9h1dKzHEtVSzIVSf2C6VBGN9DjSQYjtAdAKazZ96BSDYTVd3xqazrmIvyMKeCNzgcESsWdgmr0II3ec6aUMcbe0EHYlcExYTWEjv-2Fm-2FHt1jtoP5r0dgiLOP-2BxY5cgnjSI0L2QbvlT3yhOgAtnVJhqAcw8a4-3D"
                                                            style="font-family:Whitney,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;color:#7289da"
                                                            target="_blank"
                                                            data-saferedirecturl="https://www.google.com/url?q=https://url9624.discordapp.com/ls/click?upn%3DqDOo8cnwIoKzt0aLL1cBeHLasbud5D3vi74o1Q-2B2VLcLLCDOodJpEqop-2Fc-2F5Wr6ZjdI4_av9jLgVz1hP-2FL23lkyqaU7Iw5z8d9cjUxeAc64zG-2BCrkrwGzXJ0UvMvbPbh0CuPQmfNZNY-2FILyobSO4P9h1dKzHEtVSzIVSf2C6VBGN9DjSQYjtAdAKazZ96BSDYTVd3xqazrmIvyMKeCNzgcESsWdgmr0II3ec6aUMcbe0EHYlcExYTWEjv-2Fm-2FHt1jtoP5r0dgiLOP-2BxY5cgnjSI0L2QbvlT3yhOgAtnVJhqAcw8a4-3D&amp;source=gmail&amp;ust=1623380898827000&amp;usg=AFQjCNGqElMrsFM6MXSTUB1UeAxFcDL82A">@discord</a>.<br>
                                                        Want to give us feedback? Let us know what you think on our <a
                                                            href="https://url9624.discordapp.com/ls/click?upn=qDOo8cnwIoKzt0aLL1cBeGtifxhyb-2FEeTgeN31uAkBS2ZTvlNepPcLUnXgSC4-2BGKDJZ5_av9jLgVz1hP-2FL23lkyqaU7Iw5z8d9cjUxeAc64zG-2BCrkrwGzXJ0UvMvbPbh0CuPQ6TPLy9Qw8RLDdQqa-2FGwL6WJ8SBN1HwsACYgJU0ZE50Kkvc-2FIGtT3tspc5SN4pHdHBIV8MtzgM-2BrnV3KjlcRIWn4vrC8B-2B9ksewMuGYtz4X6GydIKgiWPWq5422hkh0NSDjiMtG6Oeczuo8aO2aeOHslFx7hJ8Xw-2FoHl-2Bo9RvsZ0-3D"
                                                            style="font-family:Whitney,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;color:#7289da"
                                                            target="_blank"
                                                            data-saferedirecturl="https://www.google.com/url?q=https://url9624.discordapp.com/ls/click?upn%3DqDOo8cnwIoKzt0aLL1cBeGtifxhyb-2FEeTgeN31uAkBS2ZTvlNepPcLUnXgSC4-2BGKDJZ5_av9jLgVz1hP-2FL23lkyqaU7Iw5z8d9cjUxeAc64zG-2BCrkrwGzXJ0UvMvbPbh0CuPQ6TPLy9Qw8RLDdQqa-2FGwL6WJ8SBN1HwsACYgJU0ZE50Kkvc-2FIGtT3tspc5SN4pHdHBIV8MtzgM-2BrnV3KjlcRIWn4vrC8B-2B9ksewMuGYtz4X6GydIKgiWPWq5422hkh0NSDjiMtG6Oeczuo8aO2aeOHslFx7hJ8Xw-2FoHl-2Bo9RvsZ0-3D&amp;source=gmail&amp;ust=1623380898827000&amp;usg=AFQjCNGGgA4WPpC4yOpWcZL5KCJP9Tw_3w">feedback
                                                            site</a>.</p>

                                                </div> -->
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        </body>

        </html>
        """.format(user.username, url)

        sender = {"name": "ADMIN_LISA", "email": '*****@*****.**'}
        to = [{"email": user.email, "name": user.username}]
        #reply_to = {"email":'*****@*****.**',"name":'ADMIN_LISA'}#{"email":"*****@*****.**","name":"John Doe"}
        headers = {"Some-Custom-Name": "unique-id-1234"}
        params = {"parameter": "My param value", "subject": "New Subject"}
        send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(
            to=to,
            headers=headers,
            html_content=html_content,
            sender=sender,
            subject=subject)

        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)
Ejemplo n.º 16
0
def web_checkout(request):
    DEFAULT_RETIRE_HOUR = 10
    # get or create user
    email = request.POST.get("email")
    random_token = ''.join(
        random.choices(string.ascii_uppercase + string.digits, k=5))
    try:
        user = CustomUser.objects.get(email=email)
        user.phone_number = request.POST.get("phone_number")
        user.save()
    except:
        user = CustomUser.objects.create_user(
            email=request.POST.get("email"),
            password=random_token,
            confirm_password=random_token,
            full_name=request.POST.get("full_name"),
            phone_number=request.POST.get("phone_number"))
    cart_list = json.loads(request.POST.get('cart_list'))
    retire_time = request.POST.get('retire_time')
    retire_hour = DEFAULT_RETIRE_HOUR
    order_comments = request.POST.get('comments') or ''
    order = create_order_for_user(cart_list, retire_time, retire_hour,
                                  order_comments, user, 1)

    email_attrs = {
        'FULL_NAME': order.user.full_name,
        'ORDER_ID': order.id,
        'ORDER_DESCRIPTION': order.description,
        'ORDER_RETIRE_TIME': arrow.get(order.retire_time).format('DD/MM/YYYY')
    }

    api_instance = sib_api_v3_sdk.TransactionalEmailsApi(
        sib_api_v3_sdk.ApiClient(configuration))
    send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(
        to=[{
            "email": order.user.email,
            "name": order.user.full_name
        }],
        template_id=1,
        params=email_attrs,
        headers={
            "charset": "iso-8859-1",
            "Content-Type": "text/html;charset=iso-8859-1"
        })  # SendSmtpEmail | Values to send a transactional email

    #m = Mailin("https://api.sendinblue.com/v3", settings.SENDINBLUE_KEY)
    # data = {
    #     "id": 7,
    #     "to": order.user.email,
    #     "bcc": "*****@*****.**",
    #     "replyto": "*****@*****.**",
    #     "attr": email_attrs,
    #     "headers": {"Content-Type": "text/html;charset=iso-8859-1"}
    # }
    #
    # result = m.send_transactional_template(data)
    try:
        # Send a transactional email
        result = api_instance.send_transac_email(send_smtp_email)
    except ApiException as e:
        print("Exception when calling SMTPApi->send_transac_email: %s\n" % e)
    print(result)
    return redirect('post_checkout')