Why does this email go to my gmail account but not my school account?
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 => "meltzerj@wharton.upenn.edu", :subject => "DreamStill is Back")
#mail(:to => user.email, :subject => "DreamStill is Back")
end
And I have an 开发者_如何学Pythonemail.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 meltzerj@wharton.upenn.edu. However, if I instead email it to my gmail account, I receive it. Why is this?
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.
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
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:
config.action_mailer.raise_delivery_errors = false
精彩评论