Sendgrid template are not loading after passing template_id
userrails opened this issue · comments
Hi,
I have updated sendgrid-rails version to 3.1.0 to use sendgrid template. My code is something like this:
class WelcomeMailer < ApplicationMailer
default :from => 'noreply@domain.com'
def welcome
mail( :to => "myemail@domain.com",
:subject => 'Welcome to my site', :template_id => "sendgrid template id")
end
end
<Mail::Message:47286004320480,
Multipart: false, Headers: <Date: Wed, 08 Mar 2017 14:44:32 +0545>, <From: noreply@domain.com>, <To: dummy@email.com>, <Message-ID: 58bfc7f44e7ff_28452b019e81b990462ca@siv-Aspire-E5-575G.mail>, <Subject: Welcome to my site>, <Mime-Version: 1.0>, <Content-Type: text/html>, <Content-Transfer-Encoding: 7bit>, <template-id: 9be09f75-xxxx-xxxx-xxxx-f00cf0ac360b>, <X-SMTPAPI: {"to":[ "myemail@domain.com" ]}>>
Email is send to myemail@domain.com but template is not loaded. Please check this issue, thank you.
Regards,
Shiv Raj
Hello, @userrails
Instead of passing a key to mail
method, try calling the template_id
method:
class WelcomeMailer < ApplicationMailer
default :from => 'noreply@domain.com'
def welcome
template_id('sendgrid template id')
mail(to: 'myemail@domain.com', subject: 'Welcome to my site')
end
end
Thank you!