使用 Shoppe gem + Rails 发送电子邮件
Sending emails using Shoppe gem + Rails
正在尝试通过专柜 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”
上设置邮件程序
购买后,您会收到一封电子邮件。
正在尝试通过专柜 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”
上设置邮件程序购买后,您会收到一封电子邮件。