0

Heroku でカスタム メーラーが送信しない場合、エラーはまったく発生しません。これはログです -

Spree::HmsCommunicator#progress_email: processed outbound mail in 5.5ms
=> nil

開発中は完全に正常に動作します-

Spree::HmsCommunicator#progress_email: processed outbound mail in 1178.4ms
Sent mail to blah@thehandbagspa.com (983.0ms)
Date: Tue, 19 Jan 2016 08:30:54 +0000
From: blah@thehandbagspa.com
To: blah@thehandbagspa.com
Message-ID: <569df43e70279_fe9a3ff1ae06020465535@Andrews-MacBook-Pro.local.mail>
Subject: Handbag Update | The Handbag Spa
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="--==_mimepart_569df43e6d9de_fe9a3ff1ae0602046541e";
 charset=UTF-8
Content-Transfer-Encoding: 7bit
track-opens: true

application.rb -

  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :postmark
  config.action_mailer.perform_deliveries = true
  config.action_mailer.postmark_settings = { :api_token => "***...." }

hms_communicator.rb -

module Spree
  class HmsCommunicator < BaseMailer
    require 'twilio-ruby'
    def progress_email(handbag, stage, movedTo)
      @handbag = handbag
      @stage = stage
      @movedTo = movedTo
      mail(:subject => 'Handbag Update | The Handbag Spa',
           :to  => @handbag.user.email,
           :from => 'blah@thehandbagspa.com',
           :track_opens => 'true')
      #send_text_message
    end

    def test_email
      mail(:subject => 'Handbag Update | The Handbag Spa',
           :to  => 'blah@thehandbagspa.com',
           :from => 'blah@thehandbagspa.com',
           :body => 'hey',
           :track_opens => 'true')
    end

    def send_text_message
      account_sid = '****...'
      auth_token = '****...'
      alphanumeric_id = "TheHandbagS"
      twilio_phone_number = '+..'
      recipient_phone_number = '+..'

      client = Twilio::REST::Client.new(account_sid, auth_token)
      begin
        client.messages.create(
          from: alphanumeric_id,
          to:   recipient_phone_number,
          body: "Hello Freya. We have received your item into the spa. It will be enjoying it's first treatment shortly. Love, The Handbag Spa"
        )
      rescue Twilio::REST::RequestError => error
        if error.code == 21612
          client.messages.create(
            from: twilio_phone_number,
            to:   recipient_phone_number,
            body: "Hello, this is a message from Andrew"
          )
        else
          # handle this some other way
          raise error
        end
      end
    end


  end
end

コンソールからこれらのメール コマンドをローカルで試すと正常に動作し、コンソールにメールが返されますが、heroku コンソールでは nil オブジェクトが返されます -

Spree::HmsCommunicator#progress_email: processed outbound mail in 5.0ms => #<ActionMailer::Base::NullMail:0x007fc9cc5c19b0>

しかし、これは Heroku コンソールでうまく動作しますか?? -

ActionMailer::Base.mail(from: "test@example.co", to: "valid.recipient@domain.com", subject: "Test", body: "Test").deliver_now

私はここで死にそうです、助けが必要です!

4

0 に答える 0