Not receiving emails from Pony when I switched wifi networks.

35 views
Skip to first unread message

Kurt Schnelker

unread,
Feb 2, 2016, 9:05:19 PM2/2/16
to Ponyrb
Forgive me if this is simple, but I'm new to programming. I built a small website w/a contact page that I have not yet launched. While i was out today, I got pony to send a couple messages to my gmail account while serving with site with shotgun. Now, I come home and tried it again, but I never receive an email. The site appears to be working fine, after I submit my message it redirects to the correct page. here is some code:

post '/contact' do
  Pony.mail({from:"Ken's",
            to:'newhavensm...@gmail.com',
            subject:'A message from ' + params[:name] + ' :' + params[:email],
            body:params[:comment]
            })
  redirect '/success'
end

Do I need to set the :via and :via_options options? If so, how did I send two mails successfully w/o them?

Thanks,
Kurt 

Ben Prew

unread,
Feb 2, 2016, 9:09:34 PM2/2/16
to pon...@googlegroups.com
Kurt,

What OS are you running on your site? If you're using Linux, you can
check /var/log/mail.log or /var/log/maillog to see if there are any
error messages sending your mail. I'm assuming there were no errors
in the shotgun logs?

Depending on how you're sending email, you may want to use Gmail's
SMTP servers to send the email, you're less likely to get blocked or
have your email marked as spam. There's an example in the readme:
https://github.com/benprew/pony

Pony.mail({
:to => 'y...@example.com',
:via => :smtp,
:via_options => {
:address => 'smtp.gmail.com',
:port => '587',
:enable_starttls_auto => true,
:user_name => 'user',
:password => 'password_see_note',
:authentication => :plain, # :plain, :login, :cram_md5, no
auth by default
:domain => "localhost.localdomain" # the HELO domain
provided by the client to the server
}
})

Thanks and good luck!
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Ponyrb" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ponyrb+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Kurt Schnelker

unread,
Feb 2, 2016, 9:32:34 PM2/2/16
to Ponyrb, b...@throwingbones.com
Ben,

Thanks for the quick response. Unfortunately I'm on a Mac, so I can't check /maillog. Everything appears normal in the shotgun logs as well. I did get it to work using the via: smtp option, using my own gmail username and password. I understand I am to use an application specific password when I put it on a server, but even then is the password secure on the server? I used my personal account when I tested it and don't feel comfortable having it on a server even with the app password. I tried using the address I'm sending it to, but Google blocked the sign in because my app doesn't meet Google's security standards. Sorry, that's a lot of info, but I'm at a loss for people to bounce ideas off of.

Thanks,
Kurt
>>>             to:'newhaven...@gmail.com',

Ben Prew

unread,
Feb 3, 2016, 1:32:57 PM2/3/16
to pon...@googlegroups.com
Kurt,

The issue you're running into is authentication, or basically "How do
other mail servers know that my mail server is allowed to send
email?". This comes up because most mail servers will reject messages
they think are from spammers.

It's generally pretty common to store auth credentials (user/password)
on a server, but I understand your hesitancy. I wouldn't use your
personal account. I would setup a separate account for the website
you're creating.

Also, you only need an application specific password if you're using
2-factor auth for gmail (which you should setup anyway).

If you don't want to put your username and password on the server, you
can setup reverse DNS, SPF and DKIM for the domain name that's sending
the email. Then when you send email, the receiving server can check
your DNS records to make sure that your ip address is allowed to send
email. Here's a good article on it:

https://wiki.zimbra.com/wiki/Best_Practices_on_Email_Protection:_SPF,_DKIM_and_DMARC

Let me know if you have any other questions, and good luck!

Kurt Schnelker

unread,
Feb 3, 2016, 5:59:15 PM2/3/16
to Ponyrb, b...@throwingbones.com
thanks for the info, Ben!
Reply all
Reply to author
Forward
0 new messages