如何检查先前是否存在标题

时间:2017-06-19 14:15:11

标签: ruby email ruby-on-rails-4 actionmailer email-headers

我通过循环通过mailer.rb中的函数发送多封电子邮件。在每封邮件之前,我设置了一个X-SMTPAPI标题,因为它们都通过一个函数,邮件后标题不会被重置。

我上google将该标题密钥设置为nil会重置整个标头,但问题出现在循环中的第一封电子邮件中。我不知道如何检查标头是否已经存在。

我只是想知道如何在ActionMailer中检查标头是否存在。

更新: - 这是我的邮件程序类代码(类Edumailer< ActionMailer :: Base)

def mailer(....)
    headers "X-SMTPAPI" => { unique_args: { webhook_id: webhook.id }}.to_json
    mail(to: to, subject: subject, body: body, bcc: bcc, cc: cc, content_type: content_type)
end



def publish_lecture(emails, course_name, course_id, body)
    emails.each {|email|
        self.mailer(:to => email, :body => body, :content_type => "text/html", :subject => "Content Added into course #{course_name}",webhookable_type: "Course", webhookable_id: course_id ,purpose: __method__.to_s).deliver
}
end

所以通过publish_lecture发送多封电子邮件,并在邮件发送前在邮件程序中设置标题,以便进一步移动,所有前面的电子邮件都包含以前邮件的标题。

每封电子邮件后我想重置一次。

0 个答案:

没有答案
相关问题