为什么这封电子邮件会发送到我的 Gmail 帐户而不是我的学校帐户?
我构建了一个自定义 rake 任务来向我的用户发送电子邮件,但我想在发送之前先测试电子邮件。
我有这个 rake 文件:
namespace :send_out do
task :generate_url => :environment do
SignedUser.all.each do |user|
#user.build_invitation
#user.generate_url
end
end
task :email => :environment do
#SignedUser.all.each do |user|
UserMailer.email.deliver
#end
end
task :all => [:generate_url, :email]
end
运行 rake send_out:all
会触发电子邮件操作:
def email
#@signed_user = user
mail(:to => "[email protected]", :subject => "DreamStill is Back")
#mail(:to => user.email, :subject => "DreamStill is Back")
end
并且我有一个用于电子邮件的 email.html.erb
文件。
当我运行 heroku rake send_out:all --trace
时,我在日志中得到了这个:
** Invoke send_out:all (first_time)
** Invoke send_out:generate_url (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute send_out:generate_url
** Invoke send_out:email (first_time)
** Invoke environment
** Execute send_out:email
Rendered user_mailer/email.html.erb (0.5ms)
** Execute send_out:all
所以看起来一切都被调用了,但我没有收到 [电子邮件受保护]。但是,如果我通过电子邮件将其发送到我的 Gmail 帐户,我就会收到它。这是为什么呢?
I built a custom rake task to send emails to my users, but I want to test the email first before sending it.
I have this rake file:
namespace :send_out do
task :generate_url => :environment do
SignedUser.all.each do |user|
#user.build_invitation
#user.generate_url
end
end
task :email => :environment do
#SignedUser.all.each do |user|
UserMailer.email.deliver
#end
end
task :all => [:generate_url, :email]
end
Running rake send_out:all
triggers the email action:
def email
#@signed_user = user
mail(:to => "[email protected]", :subject => "DreamStill is Back")
#mail(:to => user.email, :subject => "DreamStill is Back")
end
And I have an email.html.erb
file for the email.
When I run heroku rake send_out:all --trace
, I get this in my logs:
** Invoke send_out:all (first_time)
** Invoke send_out:generate_url (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute send_out:generate_url
** Invoke send_out:email (first_time)
** Invoke environment
** Execute send_out:email
Rendered user_mailer/email.html.erb (0.5ms)
** Execute send_out:all
so it seems like everything is being called, but I'm not receiving the email at [email protected]. However, if I instead email it to my gmail account, I receive it. Why is this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我刚刚尝试使用 telnet smtp 到 wharton.upenn.edu(basalt.wharton.upenn.edu) 列出的 mx 服务器,在收到“邮件来自:”后立即收到 5.7.1 访问被拒绝的消息,我通常发现这是是垃圾邮件过滤器的东西。
这意味着服务器正在执行一些操作,例如检查连接的 ip 的 helo 域或执行反向 dns 检查、spf 等...
我对 heroku 有点模糊,但我猜这是从您的本地计算机发送。如果是这样,这可能就是问题所在,因为您可能是从动态 ip(例如 comcast)发送的,而且您的 ip 无法解析为 helo 中的域名。
我会在 heroku 服务器上尝试一下,你可能不会遇到这个问题。
I just tried a telnet smtp to the mx server listed for wharton.upenn.edu(basalt.wharton.upenn.edu) and it hit me with 5.7.1 Access denied right away after a 'mail from:' which I usually find to be spam filter stuff.
What this means is that the server is doing something like checking the helo domain to the ip of the connection or doing a reverse dns check, spf etc...
I'm a little foggy on heroku, but I'm guessing that this is being sent from a your local machine. If so that is probably the problem as you are probably sending from a dynamic ip(like comcast) and also your ip doesn't resolve to the domain name in the helo.
I would try it on the heroku server and you likely won't have this issue.
我怀疑您的学校帐户将其标记为垃圾邮件,或者拒绝投递。尝试跟踪本地 MTA 的日志文件并查看其内容。
如果您的服务器使用 postfix,请尝试 tail -f /var/log/maillog | grep upenn.edu
I suspect that either your school account is marking it as spam, or is refusing delivery. Try tailing the log file for your local MTA and see what it says.
If your server is using postfix, try
tail -f /var/log/maillog | grep upenn.edu
我不确定您在什么环境中运行 rake 任务,但您可能需要检查 config/environments/*.rb 文件中的设置,这些设置可能会阻止您的电子邮件抛出类似错误:
I'm not sure what environment you're running your rake task in but you might want to check your
config/environments/*.rb
files for settings that might be keeping your email from throwing an error like: