Beispiel #1
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')
Beispiel #2
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()
Beispiel #3
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
Beispiel #4
0
import boto3
import sib_api_v3_sdk

from .app import app
from .models import db

s3 = boto3.resource("s3", endpoint_url=app.config["AWS_S3_ENDPOINT_URL"])
configuration = sib_api_v3_sdk.Configuration()
smtp = sib_api_v3_sdk.SMTPApi(sib_api_v3_sdk.ApiClient(configuration))


@app.before_request
def before_request():
    db.connect()


@app.after_request
def after_request(response):
    db.close()
    return response