Dot missing(on domain name) of password reset email link send by SendGrid

≯℡__Kan透↙ 提交于 2020-04-18 05:29:05

问题


I am using SendGrid mailer on Ruby and Rails framework. In password reset email template we are sending a password reset link which looks like the following format (https://subdomain.domainname.com/password_reset/token/?some_other_params). Most of the time the password reset link is emailed to recipient in correct format but for some customer it is not sending the proper link. The issue we noticed is "the dot is missing between (subdomain and domainname) or (domainname and com) randomly and the resulting password reset link to customer looks like (https://subdomaindomainname.com/password_reset/token/?some_other_params) which is a wrong link. This issue is happening only on production and occur very random.

I verified our variable which have domain name in our source code and verified the code which is generating the url and also thoroughly tested this and their is no issue on our source code. On google i see this question. I did't understand how to programatically solve this on SendGrid email client.

mailer.rb

class Mailer < ActionMailer::Base
  sendgrid_category Rails.env
  default_url_options[:host] = APP_URL

end

config/environments/production.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    :address => "smtp.sendgrid.net",
    :user_name => ENV['SENDGRID_USERNAME'],
    :password => ENV['SENDGRID_PASSWORD'],
    :domain => "subdomain.domainname.com",
    :port => 587,
    :authentication => "plain",
    :enable_starttls_auto => true
}

APP_URL = "subdomain.domainname.com"

mailer_helper.rb

  def link_to_with_ga(*args)
    args[1] = append_ga args[1], 'html'
    link_to *args 
  end

  def append_ga(link, utm_content)
    link << "#{link.include?('?') ? '&' : '?' }#{@ga_tag}&utm_content=#{utm_content}"
  end

_reset_password_view.rb

  <%= link_to_with_ga(t("users.reset_password"), reset_password_url(:token => @token, :locale=>@user_locale,:protocol => ( Rails.env.eql?('development') ? 'http' : 'https' )),:id => 'reset_link') %>

Please help me in solve this issue.

Thank you

来源:https://stackoverflow.com/questions/60353635/dot-missingon-domain-name-of-password-reset-email-link-send-by-sendgrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!