如何使用Actionmailer / Ruby on Rails发送具有多个动态SMTP的电子邮件 [英] How to send emails with multiple, dynamic smtp using Actionmailer/Ruby on Rails

查看:78
本文介绍了如何使用Actionmailer / Ruby on Rails发送具有多个动态SMTP的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了这篇文章,但我的帖子略有不同:

I saw this post but mine is slightly different:

带多个SMTP服务器的ActionMailer

我允许用户使用自己的SMTP凭据发送邮件,因此实际上

I am allowing the users to send mail using their own SMTP credentials so it actually does come from them.

但是它们将从Rails应用程序发送,这意味着对于每个用户,我都需要使用自己的SMTP服务器发送电子邮件。

But they will be sent from the Rails app, so that means for each user I need to send their emails using their own SMTP server.

我该怎么做?

推荐答案

只需设置ActionMailer :: Base

Just set the ActionMailer::Base configuration values before each send action.

smtp_config = user.smtp_configuration

ActionMailer::Base.username = smtp_config.username
ActionMailer::Base.password = smtp_config.password
ActionMailer::Base.server = ..
ActionMailer::Base.port = ..
ActionMailer::Base.authentication = ..

这篇关于如何使用Actionmailer / Ruby on Rails发送具有多个动态SMTP的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆