在您想要的edittext上发送包含嵌入式<a> tag in mailgun

时间:2016-03-29 18:15:34

标签: html ruby-on-rails email mailgun

I am trying to embed an <a> link within the text of an email I'm sending through mailgun. What is the correct syntax?

RestClient.post "https://api:#{ENV['MAILGUN_SECRET']}"\
  "@api.mailgun.net/v3/#{ENV['MAILGUN_DOMAIN']}/messages",
  :from => "Mailgun <mailgun@#{ENV['MAILGUN_DOMAIN']}>",
  :to => "#{@lead.email}",
  :subject => "Test",
  :text => "Here is the message, here(http://www.foo.com) is the link"

1 个答案:

答案 0 :(得分:0)

我不认为你可以发送&#34;文本&#34;使用HTML发送电子邮件,您必须选择一个 我喜欢发送所有电子邮件HTML

这就是我的邮件的样子:

class SomeMailer < ActionMailer::Base
  def email_method(post_id, lead_id)
    @post = Post.find(post_id)
    @lead = Lead.find(lead_id)
    mail(
        :from => "Email Sender<info@example.com>",
        :to =>   @lead.email,
        :reply_to => 'Email Sender<info@example.com>',
        :subject => "Test"
    )
  end
end

现在这是有趣的部分。在SomeMailer中创建一个名为app/views的文件夹,以便最终得到app/views/some_mailer

现在在名为email_method.html.erb的目录中创建一个包含html的文件:

  Here is the message, here(<a href="http://www.foo.com"> foo.com </a>) is the link

我希望这有助于