Пример #1
0
 def client(self):
     ctx = stack.top
     if ctx is not None:
         if not hasattr(ctx, 'postmark_client'):
             ctx.postmark_client = PostmarkClient.from_config(
                 current_app.config, is_uppercase=True)
         return ctx.postmark_client
Пример #2
0
def SendEmail(attachment, body):
    from postmarker.core import PostmarkClient
    
    strbody = "Please find attached the cost associated to Work Orders for the previous week.</br></br><table><tr><t2>Global Work Orders Cost</t2></tr><tr>"
    strbody += "<td>Work Order Type<td>Number of Work Orders<td>Total Cost per Type</tr>"
    
    totalnb = 0
    totalcost = 0
    
    for bod in body:
        strbody +='<td>' + bod[0] + ": <td>" + str(bod[1]) + "<td>" + str(bod[2]) + "</tr>"
        totalnb += bod[1]
        totalcost += bod[2]
    
    strbody += '<td>Grand Total: <td>' + str(totalnb) + '<td>' + str(totalcost) + '</tr>'
    strbody +='</table>'
    
    postmark = PostmarkClient(server_token=config.getpostmarktoken())
    postmark.emails.send(
                         From='*****@*****.**',
                         To='*****@*****.**',
                         Cc='*****@*****.**',
                         Subject='Weekly Work Orders cost',
                         HtmlBody= strbody,
                         Attachments = [attachment]
                         )
    return
Пример #3
0
    def email_profile_to(self, to_email):
        message = (f"{self.get_full_name()} has just signed up on the portal."
                   f"Their email is {self.user.email}.")
        email_vars = {
            "preheader": "",
            "title": "New member signup",
            "message": message
        }
        email_string = render_to_string("email_without_button.html", {
            "email": email_vars,
            "config": config
        })
        subject = "A new member signed up! ({})".format(self.get_full_name())

        postmark = PostmarkClient(server_token=config.POSTMARK_API_KEY)
        postmark.emails.send(
            From=config.EMAIL_DEFAULT_FROM,
            To=to_email,
            Subject=subject,
            HtmlBody=email_string,
        )

        log_user_event(
            self.user,
            "Sent email with subject: " + subject,
            "email",
            "Email content: " + email_string,
        )
        return True
Пример #4
0
    def post(self, request, format=None):
        token = request.data.get('token', None)
        subject = request.data.get('subject', None)
        message = request.data.get('message', None)
        receiver = request.data.get('receiver', None)

        if token:
            try:
                integration = PostmarkIntegration.objects.get(token=token)
            except PostmarkIntegration.DoesNotExists:
                return Response('Integration not found',
                                status=status.HTTP_404_NOT_FOUND)

            if integration.url != request.META.get('HTTP_ORIGIN'):
                return Response('Origin not allowed',
                                status=status.HTTP_400_BAD_REQUEST)

            postmark = PostmarkClient(
                server_token=integration.postmark_api_token)
            postmark.emails.send(From=integration.from_email,
                                 To=integration.to_emails.split(','),
                                 Subject=subject,
                                 HtmlBody=message)

            return Response('Sent', status=status.HTTP_201_CREATED)

        return Response('Token is missing', status=status.HTTP_404_NOT_FOUND)
Пример #5
0
def send_email(stock_code, error: str):
    sender_email = config.sender_email
    receiver_email = config.receiver_email

    message = MIMEMultipart("alternative")
    message["Subject"] = config.subject
    message["From"] = sender_email
    message["To"] = receiver_email

    html = """
        <html>
          <body>
            <br>
            <p><b>Error threshold exceeded while adding an adjustment to Sage</b><br>
            <br>
               While updating the following product: {stock_code}, {max_errors} consecutive errors have occurred<br>
               <br>
               The last error received from Sage was:<br><br>
                <i>{error}</i>
            </p>
          </body>
        </html>

    """.format(stock_code=stock_code, error=error, max_errors=config.maximum_errors)

    postmark = PostmarkClient(server_token=config.postmarker_token)

    postmark.emails.send(
            From=sender_email,
            To=receiver_email,
            Subject=config.subject,
            HtmlBody=html
            )
Пример #6
0
def send_single_email(
    user: object,
    email: object,
    subject: object,
    title: object,
    message: object,
) -> object:
    message = escape(message)
    message = message.replace("~br~", "<br>")
    email_vars = {"preheader": "", "title": title, "message": message}
    email_string = render_to_string(
        "email_without_button.html", {"email": email_vars, "config": config}
    )

    postmark = PostmarkClient(server_token=config.POSTMARK_API_KEY)
    postmark.emails.send(
        From=config.EMAIL_DEFAULT_FROM, To=email, Subject=subject, HtmlBody=email_string
    )

    log_user_event(
        user,
        "Sent email with subject: " + subject,
        "email",
        "Email content: " + message,
    )
    return True
Пример #7
0
def send_email(html, subject):
    postmark = PostmarkClient(server_token=TOKEN)
    postmark.emails.send(From='*****@*****.**',
                         To='*****@*****.**',
                         Subject=subject,
                         HtmlBody=html)
    print(f"email sent: {subject})")
    return
Пример #8
0
def send_email(text):
    postmark = PostmarkClient(server_token=POSTMARK_API_KEY)

    postmark.emails.send(
        From=POSTMARK_SENDER,
        To='*****@*****.**',
        Subject='Новый вопрос',
        HtmlBody=text
    )
Пример #9
0
 def client(self) -> PostmarkClient:
     ctx = stack.top
     if ctx is not None:
         if not hasattr(ctx, "postmark_client"):
             app = self._get_app()
             ctx.postmark_client = PostmarkClient.from_config(
                 app.config, is_uppercase=True)
         return ctx.postmark_client
     raise RuntimeError("Context stack is empty")
Пример #10
0
def send_email(subject: str = "Opal email test",
               email_body: str = "HTML body goes here",
               email_to: str = "*****@*****.**",
               email_from: str = "*****@*****.**"):
    postmark = PostmarkClient(server_token=POSTMARK_API_TOKEN)
    postmark.emails.send(From=email_from,
                         To=email_to,
                         Subject=subject,
                         HtmlBody=email_body)
Пример #11
0
def SendEmail(attachment):
    from postmarker.core import PostmarkClient
    postmark = PostmarkClient(server_token=config.getpostmarktoken())
    postmark.emails.send(
        From='*****@*****.**',
        To='*****@*****.**',
        Cc='*****@*****.**',
        Subject='Monthly Directory cost',
        HtmlBody=
        'Please find attached the cost associated to Directories for the previous month.',
        Attachments=[attachment])
    return
Пример #12
0
def SendEmail(attachment):
    from postmarker.core import PostmarkClient
    postmark = PostmarkClient(server_token=config.getpostmarktoken())
    postmark.emails.send(
        From='*****@*****.**',
        To='*****@*****.**',
        Cc='*****@*****.**',
        Subject='Community API Errors',
        HtmlBody=
        'Please find attached the Work Orders in API Errors after the Community Audit.',
        Attachments=[attachment])
    return
def SendEmail(attachments):
    from postmarker.core import PostmarkClient
    postmark = PostmarkClient(server_token=os.environ['API_KEY_POSTMARK'])
    postmark.emails.send(
        From='*****@*****.**',
        To='*****@*****.**',
        Cc='*****@*****.**',
        Subject='Weekly Facebook Community Results',
        HtmlBody=
        'Please find attached the Facebook Community Results associated to Work Orders for the previous week.',
        Attachments=[attachments[0], attachments[1]])
    return
Пример #14
0
def SendEmail(attachments):
    from postmarker.core import PostmarkClient
    postmark = PostmarkClient(server_token=config.getpostmarktoken())
    postmark.emails.send(
        From='*****@*****.**',
        To='*****@*****.**',
        Cc='*****@*****.**',
        Subject='Weekly Facebook Community Results',
        HtmlBody=
        'Please find attached the Facebook Community Results associated to Work Orders for the previous week.',
        Attachments=[attachments[0], attachments[1]])
    return
Пример #15
0
def remind(request):
    #send_mail('Steeplechaser Reminder Email','Here is the message','*****@*****.**',['*****@*****.**'])
    postmark = PostmarkClient(server_token='bb3a7634-2ec0-410d-9808-c39b4921af8c')
    postmark.emails.send(
        From='*****@*****.**',
        To='*****@*****.**',
        Subject='Steeplechaser Reminder',
        HtmlBody='<html><body><strong>Hello</strong> Remember your goal today!</body></html>')
    #hr = HttpRequest()
    #hr.method = 'POST'
    #hr.META['SERVER_NAME'] = 
    return HttpResponse("Hello, world. You're at steeplechaser.remind")
Пример #16
0
def SendEmail(attachment, body):

    from postmarker.core import PostmarkClient

    strbody = "Please find attached the cost associated to Work Orders for the previous month."

    postmark = PostmarkClient(server_token=os.environ['API_KEY_POSTMARK'])
    postmark.emails.send(From='*****@*****.**',
                         To='*****@*****.**',
                         Cc='*****@*****.**',
                         Subject='Monthly Work Orders cost',
                         HtmlBody=strbody,
                         Attachments=[attachment])
    return
Пример #17
0
 def __send_email(self, subject, body):
     postmark = PostmarkClient(server_token=config.POSTMARK_API_KEY)
     postmark.emails.send(
         From=config.EMAIL_DEFAULT_FROM,
         To=self.email,
         Subject=subject,
         HtmlBody=body,
     )
     log_user_event(
         self,
         "Sent email with subject: " + subject,
         "email",
         "Email content: " + body,
     )
     return True
Пример #18
0
def SendEmail(attachment):
    from postmarker.core import PostmarkClient
    
    strbody = ("Please find attached the list of all Category Mapping Work Orders that are in a Not Started status. " +
              "This list includes Work Orders for canceled locations and clients as active locations can share the same Category")

    
    postmark = PostmarkClient(server_token=config.getpostmarktoken())
    postmark.emails.send(
                         From='*****@*****.**',
                         To='*****@*****.**',
                         Cc='*****@*****.**',
                         Subject='Weekly Not Started Category Mapping Work Orders',
                         HtmlBody= strbody,
                         Attachments = [attachment]
                         )
    return
Пример #19
0
def SendEmail(attachment, arrays):
    from postmarker.core import PostmarkClient
    postmark = PostmarkClient(server_token=config.getpostmarktoken())
    body  = 'Please find below the Average Time to Complete per Work Order type for Work Orders of the previous week. A file with the average time to complete per user is attached.</br></br><table><tr><t2>Average Time to Complete in seconds</t2></tr>'
    body = body + '<tr>'
    for arr in arrays:
        body = body + '<td>' + arr[0] + ": <td>" + str(arr[1]) + "</tr>"
    
    body = body + '</table>'
    postmark.emails.send(
                         From='*****@*****.**',
                         To='*****@*****.**',
                         Cc='*****@*****.**',
                         Subject='Weekly Time to Complete',
                         HtmlBody= body,
                         Attachments=[attachment]
                         )
    return
Пример #20
0
def send_email_to_admin(
    subject: object,
    title: object,
    message: object,
):
    message = escape(message)
    message = message.replace("~br~", "<br>")
    email_vars = {"preheader": "", "title": title, "message": message}
    email_string = render_to_string(
        "email_without_button.html", {"email": email_vars, "config": config}
    )

    postmark = PostmarkClient(server_token=config.POSTMARK_API_KEY)
    postmark.emails.send(
        From=config.EMAIL_DEFAULT_FROM,
        To=config.EMAIL_ADMIN,
        Subject=subject,
        HtmlBody=email_string,
    )
Пример #21
0
def send_mail_task(token, subject, message, attachments, recipient_list,
                   from_email):
    logger.info("Sending scheduled Email")
    client = PostmarkClient(server_token=token)
    logger.info("Authenticated with Postmark")
    if not from_email or from_email in ['None', 'none', 'null', '']:
        from_email = get_secret("postmark_from_email")

    try:
        client.emails.send(
            From=from_email,
            To=recipient_list,
            Subject=subject,
            HtmlBody=message,
            Cc=get_secret("postmark_cc_email")
            if get_secret("postmark_cc_email") else None,
            Bcc=get_secret("postmark_bcc_email")
            if get_secret("postmark_bcc_email") else None,
        )
    except Exception as e:
        logger.error("Error when sending Postmark email.")
        logger.error(e)
Пример #22
0
def send_mail(subject,
              message,
              recipient_list,
              from_email=None,
              attachments=[]):
    #c = main.models.Configuration.objects.first()  # lazy-load
    # postmark = PostmarkClient(server_token=c.post_mark_key)
    postmark = PostmarkClient(token='400be863-1b90-4a8d-84e5-9be9a2d9b455')

    if not from_email:
        # from_email = c.from_email
        from_email = '*****@*****.**'
    print("Sending Email to ", recipient_list)
    sent_email = postmark.emails.send_batch(*[{
        'To': recipient,
        'From': from_email,
        'Subject': subject,
        'HtmlBody': message,
        'Attachments': attachments
    } for recipient in recipient_list])
    print(sent_email)
    return sent_email
Пример #23
0
    def run(self):
        export_to_pdf_use_case = ExportToPDFUseCase(self._user_id, self._suite_id, self._selected_options)
        export_to_pdf_use_case.run()
        pdf = export_to_pdf_use_case.get_pdf()
        suite_data_access = GetSuiteDataAccess(self._user_id, self._suite_id)
        suite = suite_data_access.get_suite()
        patient_data_access = GetPatientDataAccess(self._user_id, suite.patient_id)
        patient = patient_data_access.get_patient()

        postmark = PostmarkClient(os.getenv('POSTMARK_KEY', config('POSTMARK_KEY')))

        email = postmark.emails.Email(
            From='*****@*****.**',
            To=patient.mail,
            Subject='Notificación de PerformApp',
            HtmlBody='<html><body>Querido usuario de PerformApp, en este mensaje se adjunta la información relativa a su prueba. <br> Tenga un buen día. <br> El equipo de PerformApp.</body></html>'
        )

        email.attach_binary(content=pdf, filename='readme.pdf')

        email.send()

        return Response(status=Response.status_code)
Пример #24
0
def sendMailWIthPOSTMARKAPP():
    CONNECTION = CONNECTION_UTENTI_DA_SEGUIRE()

    try:

        #l'oggetto che ritorna è un oggetto di tipo MAIL_POSTMARKAPP, bisogna scorporarlo e poi mandare la mail
        mail_postmarkapp = CONNECTION.getMailFromDb_POSTMARKAPP()[0]
    except:
        messaggio = "POSMARKAPP MAIL - NON HO MAIL DA PROCESSARE"
        scrivoColoratoSuFile("a.html", messaggio, "red")
        return

    #Creo l'oggetto postmark
    postmark = PostmarkClient(
        server_token='f6cd8fa0-db9d-45b1-8f3e-20052de2ec9a')

    try:
        #Invio la mail
        postmark.emails.send(From='*****@*****.**',
                             To=mail_postmarkapp.EMAIL,
                             Subject=mail_postmarkapp.OGGETTO,
                             HtmlBody=mail_postmarkapp.MESSAGGIO_TEMPLATE)

        messaggio = "POSMARKAPP MAIL - Mail inviata ad " + str(
            mail_postmarkapp.EMAIL) + " con il messaggio: " + str(
                mail_postmarkapp.MESSAGGIO)
        scrivoColoratoSuFile("a.html", messaggio, "green")

    except:
        messaggio = "POSMARKAPP MAIL - Mail NON INVIATA -> " + str(
            mail_postmarkapp.EMAIL) + " con il messaggio: " + str(
                mail_postmarkapp.MESSAGGIO)
        scrivoColoratoSuFile("a.html", messaggio, "red")

    #A precindere che l'ha mandata o meno la cencello dal DB
    #Rimuovo la mail appena mandata, recupero la mail attraverso il suo ID.
    CONNECTION.removeEmailFromDb_POSTMARKAPP(mail_postmarkapp.ID)
Пример #25
0
##############################
#                            #
#  Daily Report Auto Email   #
#  by Theo Nakfoor           #
#  for Hygeia Health         #
#                            #
#  updated 4/27/2020         #
#                            #
##############################

from datetime import datetime
from postmarker.core import PostmarkClient

today = datetime.now()

postmark = PostmarkClient(server_token='###############################')

#########################################################################
californiaEmail = postmark.emails.Email(
    From='#############################',
    To='##########################',
    Subject='California Daily Report ' + today.strftime("%Y-%m-%d"),
    HtmlBody=
    '<html><body><strong>This a Hygeia automated email.</strong> Please email ########################## for questions.</body></html>'
)

californiaEmail.attach(
    '/Hygeia Daily Report/reports/California/DailyReportCA' +
    today.strftime("%Y-%m-%d") + '.xlsx')
californiaEmail.attach('/Hygeia Daily Report/reports/Texas/DailyReportTX' +
                       today.strftime("%Y-%m-%d") + '.xlsx')
Пример #26
0
from postmarker.core import PostmarkClient


FROM = '----from mail id---'

TO = ['--- to mail id---']

SUBJECT = "meeting subject"

TEXT = "this is the message for you"

# send the mail
s = PostmarkClient(server_token='--- server token---')
s.emails.send(
  From=FROM,
  To=TO,
  Subject=SUBJECT,
  HtmlBody=TEXT
)

print("mailed successfully")
Пример #27
0
def send_email_postmark(subject, message, recipient_email):
    postmark = PostmarkClient(server_token=POSTMARK_TOKEN)
    postmark.emails.send(From=EMAIL_HOST_USER,
                         To=recipient_email,
                         Subject=subject,
                         HtmlBody=message)
Пример #28
0
    def __init__(self):

        self.useremail = '*****@*****.**'
        self.token = 'fake_token'

        self.postmark = PostmarkClient(server_token=self.token)
Пример #29
0
def get_client(server_token):
    return PostmarkClient(server_token=server_token)
Пример #30
0
import re
from django.conf import settings
from postmarker.core import PostmarkClient

postmark = PostmarkClient(server_token=settings.POSTMARK_TOKEN)


def get_booking_successful_template(booking):
    template = (
        '<html>'
        '<body>'
        f'<strong>Hello {booking.booked_by.first_name.title()}, </strong>'
        '<p>You have successfully booked a flight with Airtech. Find below your ticket details.</p>'
        '<p>  </p>'
        '<p>  </p>'
        f'<p> <b style="font-size:15px;">Ticket Number: </b> {booking.id}</p>'
        f'<p> <b style="font-size:15px;">From: </b> {booking.origin.airport}, {booking.origin.city}, {booking.origin.country}</p>'
        f'<p> <b style="font-size:15px;">To: </b> {booking.destination.airport}, {booking.destination.city}, {booking.destination.country}</p>'
        f'<p> <b style="font-size:15px;">Travel Date: </b> {booking.travel_date}</p>'
        f'<p> <b style="font-size:15px;">Flight Name: </b> {booking.flight.name if booking.flight else ""}</p>'
        f'<p> <b style="font-size:15px;">Seat: </b> {booking.seat.seat if booking.seat else ""}, {booking.seat.class_group if booking.seat else ""}</p>'
        '</body>'
        '</html>')
    return template


def get_booking_reminder_template(booking):
    template = (
        '<html>'
        '<body>'
        f'<strong>Hello {booking.booked_by.first_name.title()}, </strong>'