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

Substitutions in a template #58

Closed
real-ashwin opened this issue Apr 29, 2016 · 4 comments
Closed

Substitutions in a template #58

real-ashwin opened this issue Apr 29, 2016 · 4 comments

Comments

@real-ashwin
Copy link

Question:

To substitute parameters, like -first_name-, -last_name-, etc, the only option is to use SMTP API as specified here(using-sendgrids-x-smtpapi-header). Is that correct?

I did not see any option to set substitutions directly on the Sendgrid::Mail object.

mail = SendGrid::Mail.new
mail.subs = 'IS_IT_POSSIBLE_TO_SECIFY_SUBSTITUTIONS_HERE'
@gurgelrenan
Copy link

gurgelrenan commented May 2, 2016

You could use like describe here too https://github.com/sendgrid/sendgrid-ruby#working-with-templates
I think that is not possible add a substitution direct from the Mail class

@real-ashwin
Copy link
Author

Thank you for your response @gurgelrenan

But in that API, after creating Recipients, Template and Client, the document says that you have to set the HTML while creating the TemplateMailer.

mail_defaults = {
  from: 'admin@email.com',
  html: '<h1>I like email</h1>',
  text: 'I like email',
  subject: 'Email is great'
}

This is what threw me off. Why set HTML when the template has html already?

@gurgelrenan
Copy link

gurgelrenan commented May 2, 2016

Yeah, for me look strange too, but I have searched and I found this approach:

mail_defaults = {
      from: 'no-reply@email.com',
      from_name: 'Admin',
      subject: "My subject",
      html: ' ',
      text: ' '
    }

Put HTML and Text with a ' ' empty string. It works for me.

@real-ashwin
Copy link
Author

Thanks @gurgelrenan

jamietanna pushed a commit to jamietanna/sendgrid-ruby that referenced this issue Oct 13, 2018
…odeclimate

[Closes sendgrid#55] Add code coverage reporting to CC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants