Beispiel #1
0
    def send_mail(self, ts_name, email, subscriber_key, token=None):
        """
        Send an email message to a user (Triggered Send).

        @param ts_name: the name of the message to send
        @param email: the email address of the user
        @param subscriber_key: the key for the user in SFMC
        @param format: T or H for Text or HTML
        @param token: optional token if a recovery message
        @return: None
        """
        ts = ET_TriggeredSend()
        ts.auth_stub = self.client
        ts.props = {'CustomerKey': ts_name}
        subscriber = {
            'EmailAddress': email,
            'SubscriberKey': subscriber_key,
        }
        if token:
            ts.attributes = build_attributes({
                'Token__c': token,
            })
            subscriber['Attributes'] = ts.attributes
        ts.subscribers = [subscriber]
        resp = ts.send()
        assert_response(resp)
Beispiel #2
0
    def send_mail(self, ts_name, email, subscriber_key, token=None):
        """
        Send an email message to a user (Triggered Send).

        @param ts_name: the name of the message to send
        @param email: the email address of the user
        @param subscriber_key: the key for the user in SFMC
        @param format: T or H for Text or HTML
        @param token: optional token if a recovery message
        @return: None
        """
        ts = ET_TriggeredSend()
        ts.auth_stub = self.client
        ts.props = {'CustomerKey': ts_name}
        subscriber = {
            'EmailAddress': email,
            'SubscriberKey': subscriber_key,
        }
        if token:
            ts.attributes = build_attributes({
                'Token__c': token,
            })
            subscriber['Attributes'] = ts.attributes
        ts.subscribers = [subscriber]
        resp = ts.send()
        assert_response(resp)
Beispiel #3
0
 def send(self, email_name, to, data):
     ts = ET_TriggeredSend()
     ts.auth_stub = self.client
     ts.props = {'CustomerKey': email_name}
     ts.subscribers = [{
         'EmailAddress': to,
         'SubscriberKey': to,
         'Attributes': self.build_attributes(data),
     }]
     return self.process_result(ts.send())
Beispiel #4
0
 def send(self, email_name, to, data):
     ts = ET_TriggeredSend()
     ts.auth_stub = self.client
     ts.props = {'CustomerKey': email_name}
     ts.subscribers = [{
         'EmailAddress': to,
         'SubscriberKey': to,
         'Attributes': self.build_attributes(data),
     }]
     return self.process_result(ts.send())
Beispiel #5
0
    def send_mail(self, ts_name, email, token, format):
        """
        Send an email message to a user (Triggered Send).

        @param ts_name: the name of the message to send
        @param email: the email address of the user
        @return: None
        """
        ts = ET_TriggeredSend()
        ts.auth_stub = self.client
        ts.props = {'CustomerKey': ts_name}
        ts.attributes = build_attributes({
            'TOKEN': token,
            'EMAIL_FORMAT_': format,
        })
        ts.subscribers = [{
            'EmailAddress': email,
            'SubscriberKey': token,
            'EmailTypePreference': 'HTML' if format == 'H' else 'Text',
            'Attributes': ts.attributes,
        }]
        resp = ts.send()
        assert_response(resp)