Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send different email content to different users friends list #219

Closed
loveforweb opened this issue Sep 7, 2017 · 5 comments
Closed

Send different email content to different users friends list #219

loveforweb opened this issue Sep 7, 2017 · 5 comments
Assignees
Labels

Comments

@loveforweb
Copy link

loveforweb commented Sep 7, 2017

Hi, Im trying to figure out how to send multiple transmissions in one request (an array of objects), is this possible?

Basically, I have a list of users, who each have a list of friends (recipients). For each users, I need the ability to send out an email to their friends, each user can have different email content from other users. I also need a way to pass the relevant users names to each transmission object as it will be included in the email content

So as a rough (incomplete) example, could i do the following:

transmission = [{
        recipients: [
            // {recipients objects}
        ],
        content: {
           from: {
                name: 'John Flintstone',
                email: 'hello@flintstone.com'
            },
            subject: 'Howdy!',
            reply_to: 'My Information <hello@flintstone.com>',
            text: 'Hi {{address.name}} Some other information\n {{sender}}',
            html: '<p>Hi {{address.name}} Some other information<p>{{sender}}</p>'
        }
}, {
        recipients: [
            // {recipients objects}
        ],
        content: {
           from: {
                name: 'Fred Flintstone',
                email: 'hello@flintstone.com'
            },
            subject: 'The Subject!',
            reply_to: 'My Campaign <hello@flintstone.com>',
            text: 'Hi {{address.name}} Some other information\n {{sender}}',
            html: '<p>Hi {{address.name}} Some other information<p>{{sender}}</p>'
        }
}]

Thanks in advance

@aydrian aydrian self-assigned this Sep 8, 2017
@aydrian
Copy link
Contributor

aydrian commented Sep 8, 2017

It looks like you are on the right track. You just need one transmission and content with substitution_data. You can provide substitution_data at the recipient level. This would allow you to set info like their name and info about the friend sending them the message. This substitution data gets merged into the top level substitution data. So it would look more like the following:

let transmission = {
  recipients: [
    {
      address: {
        email: 'mr_slate@bedrock.com',
        name: 'Mr. Slate'
      },
      substitution_data: {
        sender: {
          name: 'Fred Flintstone'
        }
      }
    }, {
      address: {
        email: 'bambam@bedrock.com',
        name: 'Bambam Rubble'
      },
      substitution_data: {
        sender: {
          name: 'Wilma Flintstone'
        }
      }
    }
  ],
  content: {
    from: {
      name: '{{ sender.name }}',
      email: 'hello@flintstone.com'
    },
    subject: 'Howdy!',
    reply_to: 'My Information <hello@flintstone.com>',
    text: 'Hi {{ address.name }} Some other information\n {{ sender.name }}',
    html: '<p>Hi {{ address.name }} Some other information<p>{{ sender.name }}</p>'
  }
}

I just tried this with real email addresses and it worked. Please let me know if you have any additional questions.

@loveforweb
Copy link
Author

that looks great, but is there a way where the content.subject/text/html can be different for each User? At the moment, each User is sending the same email content to their recipients, Fred Flintstone may not want to send the same content as Wilma Flintstone

@aydrian
Copy link
Contributor

aydrian commented Sep 8, 2017

You would have to figure out a way to pass the content into the template from substitution_data. It might be worth it to just send multiple transmission posts.

@loveforweb
Copy link
Author

Thats cool, I'll have a play around and see what i can create, otherwise it will have to be multiple transmissions post.

Thanks for the help @aydrian

@aydrian
Copy link
Contributor

aydrian commented Sep 8, 2017

No worries. There's no reason to squish everything into one post if it doesn't make sense. :)

@aydrian aydrian closed this as completed Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants