Recipients from external source

Sneha's Avatar

Sneha

09 Mar, 2016 01:32 PM

Hello

Can I use list of recipients from some external source like a database when I run the API from my application. I am using the trial version of postageapp and I couldnt see it available in the template. i.e if I use a template can I specify the list of recipients dynamically

  1. Support Staff 1 Posted by Scott Tadman on 09 Mar, 2016 05:22 PM

    Scott Tadman's Avatar

    The list of recipients should be sent with the send_message API call, and that's where you can reference either a pre-defined template, supply the content yourself, or a combination of those two approaches.

    Normally this list of recipients is supplied by your application when making the API call. Which plugin or programming language are you using? Each has a slightly different approach but the general idea is the same.

  2. 2 Posted by sneha on 09 Mar, 2016 05:26 PM

    sneha's Avatar

    In python or php. I read from API resource that if I use template in API call, the program just takes the name of the template and hence I asked the question.
    The whole idea is to get the list of recipients dynamically and same time use a template to send html in mail.

  3. Support Staff 3 Posted by Scott Tadman on 09 Mar, 2016 05:34 PM

    Scott Tadman's Avatar

    That's exactly the idea. In addition to the template argument, you need to specify recipients as well. This can be a single string, a comma separated list, an array, or a dictionary where each key is the email address and the values are the variables for each recipient. This allows easy personalization of message content.

    So if you can load in the list of recipients from a file, database, or form submission, you just need to repackage those into the API call. It's simple JSON so it shouldn't be too tricky to compose by hand if necessary, or using some example code for PHP as a basis.

    Here's the rough shape an API call takes:

    {
      "api_key" : "PROJECT_API_KEY",
      "arguments" : {
    
        "recipients" : ["[email blocked]", "[email blocked]"],
    
        "headers" : {
          "subject" : "Email Subject",
          "from" : "[email blocked]"
        },
        "template" : "POSTAGEAPP_TEMPLATE",
    
        "variables" : {
          "global_variable_1" : "value",
          "global_variable_2" : "value"
        }
      }
    }
    

    There's additional information available on the developer documentation site.

  4. 4 Posted by sneha on 09 Mar, 2016 06:00 PM

    sneha's Avatar

    thanks for the info. can I get a sample python app like the same you gave for php.

  5. Support Staff 5 Posted by Scott Tadman on 09 Mar, 2016 06:00 PM

    Scott Tadman's Avatar

    I don't have one immediately handy but I can try to find one for you.

  6. 6 Posted by sneha on 09 Mar, 2016 07:41 PM

    sneha's Avatar

    Great.Thanks

Discussions are closed to public comments.
If you need help with PostageApp please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

30 Apr, 2017 01:56 PM
31 Mar, 2017 10:35 PM
10 Mar, 2017 11:34 AM
09 Mar, 2017 01:23 PM
02 Feb, 2017 08:33 PM