簡體   English   中英

使用Shoppe gem + Rails發送電子郵件

[英]Sending emails using Shoppe gem + Rails

嘗試使用Shoppe gem發送已接受的訂單電子郵件通知。

production.rb

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
      :address              => "smtp.gmail.com",
      :port                 => 587,
      :user_name            => ENV['chbrown1293'],
      :password             => ENV['*******'],
      :authentication       => "plain",
      :enable_starttls_auto => true
  }

訂單控制器

  def payment
    gon.client_token = generate_client_token
    @order = Shoppe::Order.find(current_order.id)
    @result = Braintree::Transaction.sale(
        amount: current_order.total,
        payment_method_nonce: params[:payment_method_nonce])
    if @result.success?
      Shoppe::OrderMailer.accepted(@order)
      current_order.destroy
      redirect_to root_url, notice: "Payment successful, congratulations!"
    end
  end

不知道我在想什么,但它可能很明顯! (我以前從未設置過郵件收發器-我的確是菜鳥:)

謝謝!

我從未使用過Shoppe,但是在ActionMailer中,我們必須調用方法deliver才能發送電子郵件。 嘗試改變

Shoppe::OrderMailer.accepted(@order)

Shoppe::OrderMailer.accepted(@order).deliver

如果我沒有記錯的話,Shoppe在其訂單控制器下的應用程序的gemfile中內置了一個自動郵件程序。 (檢查github倉庫以確認)

為了訪問它,您應該使用郵遞員信息設置用於生產的配置文件。

還要確保在“ / shoppe / settings”上設置郵件程序

購買后,您會收到一封電子郵件。

暫無
暫無

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

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