因此,当有人填写与我们联系的表格时,我尝试发送电子邮件,但是当我添加时:
export GMAIL_USERNAME="myapp@domain.com"
export GMAIL_PASSWORD="secret"
对我
~/.bashrc
文件,并将我的development.rb
文件设置如下,我的应用程序返回一个
Net::SMTPAuthenticationError 530-5.5.1 Authentication Required
但是当我用它的实际值替换ENV["GMAIL_USERNAME"]
& ENV["GMAIL_PASSWORD"]
indevelopment.rb
时,我发送电子邮件就没有问题了。添加到~./bashrc
文件中是否不能确保ENV["GMAIL_USERNAME"]
&ENV["GMAIL_PASSWORD"]
被真实值替换?有人可以帮忙吗?
我已经尝试了谷歌的说明ENV["GMAIL_USERNAME"]
,但是当我使用&时它不起作用ENV["GMAIL_PASSWORD"]
(而不是它们的实际值)。
这是我development.rb
文件的相关部分:
# Raise error if the mailer can't send
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.default :charset => "utf-8"
# Use SMTP to send mail
config.action_mailer.delivery_method = :smtp
# Use awesomeness@novulty.com (google app) to send smtp mail
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "domain", # real domain name in my file
:user_name => ENV["GMAIL_USERNAME"],
:password => ENV["GMAIL_PASSWORD"],
:authentication => :plain,
:enable_starttls_auto => true
}
# Specify what domain to use for mailer URLs
config.action_mailer.default_url_options = {
host: "localhost:3000"
}
谢谢!
更新
我的 .bashrc 文件如下所示:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
export GMAIL_USERNAME=***********
export GMAIL_PASSWORD=***********
但是当我打开终端并输入env
时,GMAIL_*
变量没有被列出,但 rvm 被添加到PATH
. 这让我很困扰……哈哈。
再次感谢!