簡體   English   中英

MailForm gem不發送電子郵件

[英]MailForm gem not sending email

我正在嘗試使用MailForm gem設置基本的電子郵件表單,但是即使在控制台中創建新消息時,也無法實際發送電子郵件。

我正在使用Amazon的SES服務來發送電子郵件,並且它們對於諸如Devise確認消息之類的東西都工作正常,因此似乎可以正常工作。 控制台的輸出看起來也可以成功發送,但是永遠不會通過。

模型

class Contact < MailForm::Base

    attribute :name,      :validate => true
    attribute :email,     :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
    attribute :file,      :attachment => true

    attribute :message
    # attribute :nickname,  :captcha  => true

    # Declare the e-mail headers. It accepts anything the mail method
    # in ActionMailer accepts.
    def headers
      {
        :subject => "My Contact Form",
        :to => "myemailaddress@gmail.com",
        :from => %("#{name}" <#{email}>)
      }
    end
end

安慰

irb(main):001:0> c = Contact.new
=> #<Contact:0x007fe587c1c0b8>
irb(main):002:0> c.email = "hello@goodbye.com"
=> "hello@goodbye.com"
irb(main):003:0> c.name = "It's my name"
=> "It's my name"
irb(main):004:0> c.message = "No subject"
=> "No subject"
irb(main):005:0> c.deliver

控制台輸出

MailForm::Notifier#contact: processed outbound mail in 29.8ms

Sent mail to myemailaddress@gmail.com (285.5ms)
Date: Fri, 05 Sep 2014 00:17:49 -0400
From: It's my name <hello@goodbye.com>
To: myemailaddress@gmail.com
Message-ID: <5409396d8fe66_14dda3ff2c180c46c84468@Chriss-Macbook-Pro.local.mail>
Subject: My Contact Form
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<h4 style="text-decoration:underline">My Contact Form</h4>


  <p><b>Name:</b>
  It&#39;s my name</p>

  <p><b>Email:</b>
  hello@goodbye.com</p>

  <p><b>Message:</b>
  No subject</p>


=> true

問題是我正在使用Amazon的SES接收電子郵件,這要求您證明自己有權訪問電子郵件地址,然后電子郵件才能從中發送消息。 這意味着“發送”字段不能是提交表單的人的電子郵件地址,而必須是經過審查的電子郵件地址。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM