Tag: 动作管理员mailgun

如何在Mailgun HTTP API中呈现rails邮件程序视图

我正在使用Mailgun HTTP API从rails应用程序发送电子邮件。但我无法呈现邮件程序视图。 这是我的邮件课程。 class MailgunMails < ActionMailer::Base def send_complex_message data = Multimap.new data[:from] = "Excited User ” data[:to] = “alice@example.com” data[:subject] = “Hello” data[:html] = File.open(“#{Rails.root}/app/views/mailgun_mails/send_complex_message.html.erb”, ‘r’).to_s.html_safe ## also tried data[:html] = render(template: “send_complex_message.html.erb”) response = RestClient.post “https://api:#{@@private_key}”\ “@api.mailgun.net/v2/#{@@domain}/messages”, data response = JSON.parse(response) end end 但是抛出: NoMethodError:nil的未定义方法`each_byte’:NilClass 如何使用Mailgun API的邮件程序视图。 PS:我知道有很多gem可以使用带有rails的mailgun,但它们都没有像API那样提供完整的function。 如果有任何替代方法使用rails视图从api发送电子邮件,我正在等待答案。 我只是不知道该怎么做(即使它没有使用actionmailer) 完整的错误跟踪 NoMethodError: […]