Ruby on rails Rails:更改操作邮件程序中的默认发件人
我在rails应用程序中使用action mailer发送电子邮件。但它只允许一个默认发送者。这是我的UserMailer类:Ruby on rails Rails:更改操作邮件程序中的默认发件人,ruby-on-rails,ruby-on-rails-3.2,actionmailer,Ruby On Rails,Ruby On Rails 3.2,Actionmailer,我在rails应用程序中使用action mailer发送电子邮件。但它只允许一个默认发送者。这是我的UserMailer类: class UserMailer < ActionMailer::Base default :from => "example@example.com" def welcome_email(user, order) @user = user @order = order mail(:to => user.email, :subject
class UserMailer < ActionMailer::Base
default :from => "example@example.com"
def welcome_email(user, order)
@user = user
@order = order
mail(:to => user.email, :subject => "Your Order")
end
def signup_email(user)
@user = user
mail(:to => user.email, :subject => "Thank you.")
end
def invite_confirm(curuser,usemail,post)
@greeting = "Hi"
@user = curuser
@post = post
mail(:to => user.email, :subject => "Hello")
end
end
我想,我不应该在这里更改任何内容。您可以将其作为参数传递给
mail
方法:
def new_mail
mail from: "example@example.com", to: "user@example.com"
end
我想你们应该为每个动作发送三封不同的电子邮件。因为你使用gmail,所以你需要 没有哪家供应商适合所有三种类型的电子邮件;你可能 将使用多个供应商 对于“公司电子邮件”,即向客户发送个人电子邮件或 业务伙伴,你可能会使用Gmail或。对于单个地址,您可以设置单个Gmail帐户 接收和接收。更有可能, 您需要公司邮件的多个电子邮件地址。为此,, 将谷歌应用程序用于商业
我发现,使用smtp无法完成此操作。需要使用允许多发件人支持的amazon SES。以下是我使用的,它允许使“标题”不同
class UserMailer < ActionMailer::Base
default :from => '"example" <example@domain.com>'
def send_signup_email(user)
@user = user
mail(to: @user.email, subject: 'example')
end
end
class UserMailer““示例””
def发送\注册\电子邮件(用户)
@用户=用户
邮件(发送至:@user.email,主题:“示例”)
结束
结束
嘿,我想发送来自不同用户的电子邮件。我更新了我的问题。你能帮忙吗?你需要发几封电子邮件:)
def new_mail
mail from: "example@example.com", to: "user@example.com"
end
class UserMailer < ActionMailer::Base
default :from => '"example" <example@domain.com>'
def send_signup_email(user)
@user = user
mail(to: @user.email, subject: 'example')
end
end