我们有我们 API
在Ruby中用 Sinatra
创业板,并使用 Pony
来发送邮件。我想设置参数 reply-to
......我已经尝试了所有的可能性,甚至是Pony gem docs说的方式,但它根本就没有工作。
我们的邮件代码是
require 'logjam'
require 'pony'
module Evercam
module Mailers
class Mailer
LogJam.apply(self, "actors")
@@templates = {}
def initialize(inputs)
@inputs = inputs
end
def erb(name)
ERB.new(template(name)).result(binding)
end
private
def template(name)
@@templates[name] ||= File.read(
File.expand_path(File.join('.', name))
)
end
def method_missing(name)
if @inputs.keys.include?(name)
@inputs[name]
end
end
def self.method_missing(name, *inputs)
if self.method_defined?(name) && inputs[0]
begin
opts = self.new(inputs[0]).send(name)
mail = Evercam::Config[:mail].merge(opts)
Pony.mail(mail)
rescue Exception => e
log.warn(e)
end
end
end
end
end
end
require_relative 'mailer'
module Evercam
module Mailers
class UserMailer < Mailer
def confirm
{
to: user.email,
subject: 'Evercam Confirmation',
html_body: erb('templates/emails/user/confirm.html.erb'),
body: erb('templates/emails/user/confirm.txt')
}
end
def share
{
to: email,
subject: "#{user.fullname} has shared a camera with you",
html_body: erb('templates/emails/user/camera_shared_notification.html.erb'),
attachments: attachments,
reply_to: sharer
}
end
def share_request
{
to: email,
subject: "#{user.fullname} has shared a camera with you",
html_body: erb('templates/emails/user/sign_up_to_share_email.html.erb'),
attachments: attachments,
reply_to: sharer
}
end
def interested
{
to: '[email protected]',
subject: 'Signup on evercam.io',
body: erb('templates/emails/user/interested.txt')
}
end
def app_idea
{
to: '[email protected]',
subject: 'Marketplace idea on evercam.io',
body: erb('templates/emails/user/app_idea.txt')
}
end
def create_success
{
to: archive.user.email,
subject: "Archive #{archive.title} is ready.",
html_body: erb('templates/emails/user/archive_create_completed.html.erb'),
attachments: attachments
}
end
def create_fail
{
to: archive.user.email,
subject: "Archive #{archive.title} failed.",
html_body: erb('archive_creation_failed.html.erb'),
attachments: attachments
}
end
end
end
end
中的reply_to。share
并在 share_request
是在所有工作......任何帮助将被感激。 谢谢
这个问题似乎很老了,但我在问自己同样的问题时偶然发现了这个问题。文件.
你可以直接从Pony那里得到一个选项列表。
Pony.permissable_options