Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert Sending mails on a mac...

Replytotopic

Sending mails on a mac

Posted in Forums : Ask a Rails expert

 
Profile

Authority 0
Posting Rating 69
Sign in to rate this post

Hi,

I’ve written a function to send my contactform content to me.
But sometimes, it’s working and sometimes it isn’t.

http://pastie.org/500904

The log shows that the mail is send but it I’m not receiving one!

 
Pic

Authority 50
Posting Rating 37
Sign in to rate this post

Hi Wouter!

Have you set config.action_mailer.raise_delivery_errors = true for your current environment?
If not, your mailer will fail silently whether it sends or not.

You could try adding something like this to your code:

begin Notifier.deliver_contact(@contact.name, @contact.address, @contact.city, @contact.email, @contact.telephone, @contact.subject, @contact.message, @contact.language, @contact.ip)
rescue => e logger.error “Email didn’t send, error message:\n” + e
end

This will help you pinpoint whether the mail is being sent or not.

If it’s not, hopefully the error message in your log will shed some light on why not.

If it is – maybe it’s a problem with your server. It might even be getting put into your junk mail?

Hope that helps?

 
Profile

Authority 0
Posting Rating 69
Sign in to rate this post

Hi Gavin,

Thanks for your response. I think I’ve located the problem. For some reason the sendmail isn’t working.
I’ve changed the settings to smtp and now everything works fine.

It’s a good idea to put the code in a try-catch block, I’ll do that for the whole application.

 
Profile

Authority 0
Posting Rating 79
Sign in to rate this post

Hi Wouter,

OS X by default uses Postfix as it’s mail system, which provides the sendmail command. Typically you will have trouble using this to send email out to remote servers though as your development machine running on a home/broadband IP wouldn’t be a trusted source. To get around this and have sendmail work most of the time, you can set it up to relay all email through a trusted SMTP server such as your GMail account – there is a good howto on this here http://www.riverturn.com/blog/?p=239

On the plus side sorting the Postfix relay out also allows mail to work for any local PHP/Cgi/whatever development you are doing.

Replytotopic

Other Recent Topics

Ask a Rails expert : nested application ApplicationController get called intead of children::ApplicationController

Ask a Rails expert : Best way to structure a database for a large/static dataset

Ask a Rails expert : Ruby Developer (ROR) - Scottish based (Remote working from within the UK)

Ask a Rails expert : Above Ground Pool Supplies

Ask a Rails expert : How to get url params in observer or model in Rails 3.1

Ask a Rails expert : What can persuade you to hire Junior Ruby devs with significant PHP experience?

Ask a Rails expert : What industry value does the Ruby or Rails Certification currently have?

Ask a Rails expert : Louis Vuitton Damier Azur Canvas specially sale ( www.salecheaplouisvuitton.com )

Ask a Rails expert : ·How to check errors/puts statements from ruby files which are under cronob

Ask a Rails expert : Louis Vuitton cheap Soft Sided Luggagespecial offer( www.salecheaplouisvuitton.com )

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel