lundi 30 octobre 2023

Mailgun Showing Variable Names as it is Ruby on Rails

I have a template field in my object in which i store the whole email template and store it like below "<p><span style=\"font-family: -apple-system, system-ui, &quot;Segoe UI&quot;, Roboto, Oxygen-Sans, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;\">%recipient.email%<b><br></b></span><b>&nbsp;<br>&nbsp;</b><span style=\"font-family: -apple-system, system-ui, &quot;Segoe UI&quot;, Roboto, Oxygen-Sans, Ubuntu, Cantarell, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;\">%recipient.tier_name%</span></p>" in this %recipient.email% is my variable and it will changed by mailgun automatically but the issue is sometimes it does not reflect and appear as it is in the email with out changing its actaul value

example: If recipient.email = test@gmail.com but in email it is showing %recipient.email% instead of test@gmail.com

I want to apply the variable values instead of its variable names. example: If recipient.email = test@gmail.com but in email it is showing %recipient.email% instead of test@gmail.com

def self.send_emails(subject:, html:, to_emails:, recipient_variables: {}, force_send: false, sender_email)
payload = {
  from: sender_name(sender_email),
  subject:,
  html:,
  'recipient-variables': recipient_variables.to_json,
  'o:tag': [subject, tag]
}
esponse = RestClient.post(mailgun_api_url(sender_email), payload)

end

Aucun commentaire:

Enregistrer un commentaire