Actionmailer setup

374 views
Skip to first unread message

giorgio

unread,
Apr 5, 2010, 9:59:13 PM4/5/10
to Refinery CMS
Hi,
I have got Refinery running on Heroku and just need to sort out
emailing.

With other apps I have used gmail for mailing by simply sticking
something like the following at the end of environment.rb:-
require 'smtp_tls'
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com" ,
:port=>587,
:authentication => :plain ,
:user_name => "myg...@gmail.com" ,
:password => "kjhkjhkjh" ,
}

This has worked faultlessly... However I cant get Refinery to send any
emails and cant see any info on setting up Actionmailer.

Can someone help me out?

Cheers
George

Rafael MVC

unread,
Apr 6, 2010, 12:00:55 PM4/6/10
to refine...@googlegroups.com
First:

if you are using rails 2.3.5 or older, take the " require 'smtp_tls' " out,
add  " :enable_starttls_auto => true, " to it,
the :user_name shouldn't have the @gmail.com, unless is a google app domain,
and take that extra ","  after the password.

Second:
Gmail barks back at you when you send emails from yourname@localhost.
Because how refinery generate the from field, you gonna get something like it on the development machine, so a workaround is to git clone the "vendor/plugins/inquiries/" and change the mailer to a fixed address...
This is the line you are looking for:

    from        "\"#{RefinerySetting[:site_name]}\" <no-reply@#{request.domain(RefinerySetting.find_or_set(:tld_length, 1))}>"

Let me know if you need further help! :)

[]'s
Rafa


--
You received this message because you are subscribed to the Google
Groups "Refinery CMS" group.
To post to this group, send email to refine...@googlegroups.com
To unsubscribe from this group, send email to
refinery-cms...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/refinery-cms?hl=en

http://www.refinerycms.com

To unsubscribe, reply using "remove me" as the subject.

Rafael MVC

unread,
Apr 6, 2010, 12:01:48 PM4/6/10
to refine...@googlegroups.com
Sorry, i meant rails 2.3.5 or newer. I actually think it will work on any rails 2.3.3 or older. I'm using 2.3.5.

Rafael MVC

unread,
Apr 6, 2010, 12:02:45 PM4/6/10
to refine...@googlegroups.com
2.3.3 or newer! ARRR Mornings are hard for me! :)

giorgio

unread,
Apr 6, 2010, 5:13:00 PM4/6/10
to Refinery CMS
Thanks for that Rafael,

I will check out that hard coding in the inquiries gem. I wonderered
if that was the case as it always tried to send from no-
re...@heroku.com.

Thanks for the info on 2.3.3 or newer. All the apps that I use email
with are using older Rails than that but the Refinery one is 2.3.5 so
looks like I need to change the "require 'smtp_tls' " as well.

Cheers
George

On Apr 7, 4:02 am, Rafael MVC <rafa...@gmail.com> wrote:
> 2.3.3 or newer! ARRR Mornings are hard for me! :)
>

> On Tue, Apr 6, 2010 at 10:01 AM, Rafael MVC <rafa...@gmail.com> wrote:
> > Sorry, i meant rails 2.3.5 or newer. I actually think it will work on any
> > rails 2.3.3 or older. I'm using 2.3.5.
>

> > On Tue, Apr 6, 2010 at 10:00 AM, Rafael MVC <rafa...@gmail.com> wrote:
>
> >> First:
>
> >> if you are using rails 2.3.5 or older, take the " require 'smtp_tls' "
> >> out,
> >> add  " :enable_starttls_auto => true, " to it,
> >> the :user_name shouldn't have the @gmail.com, unless is a google app
> >> domain,
> >> and take that extra ","  after the password.
>
> >> Second:
> >> Gmail barks back at you when you send emails from yourname@localhost.
> >> Because how refinery generate the from field, you gonna get something like
> >> it on the development machine, so a workaround is to git clone the
> >> "vendor/plugins/inquiries/" and change the mailer to a fixed address...
> >> This is the line you are looking for:
>
> >>     from        "\"#{RefinerySetting[:site_name]}\" <no-reply@#{request.domain(RefinerySetting.find_or_set(:tld_length,
> >> 1))}>"
>
> >> Let me know if you need further help! :)
>
> >> []'s
> >> Rafa
>

> >> On Mon, Apr 5, 2010 at 7:59 PM, giorgio <george.pever...@gmail.com>wrote:
>
> >>> Hi,
> >>> I have got Refinery running on Heroku and just need to sort out
> >>> emailing.
>
> >>> With other apps I have used gmail for mailing by simply sticking
> >>> something like the following at the end of environment.rb:-
> >>> require 'smtp_tls'
> >>> ActionMailer::Base.delivery_method = :smtp
> >>> ActionMailer::Base.smtp_settings = {
> >>>  :address => "smtp.gmail.com" ,
> >>>  :port=>587,
> >>>  :authentication => :plain ,

> >>>  :user_name => "mygm...@gmail.com" ,


> >>>  :password => "kjhkjhkjh" ,
> >>> }
>
> >>> This has worked faultlessly... However I cant get Refinery to send any
> >>> emails and cant see any info on setting up Actionmailer.
>
> >>> Can someone help me out?
>
> >>> Cheers
> >>> George
>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Refinery CMS" group.
> >>> To post to this group, send email to refine...@googlegroups.com
> >>> To unsubscribe from this group, send email to

> >>> refinery-cms...@googlegroups.com<refinery-cms%2Bunsu...@googlegroups.com>

Charles

unread,
Apr 6, 2010, 6:03:22 PM4/6/10
to Refinery CMS
btw, :enable_starttls_auto in rails 2.3.5 require ruby 1.8.7, so I
think it wont work unless you use something else than the default
stack (heroku default to 1.8.6.x?)

Personally I use action_mailer_optional_tls from collectiveidea, work
great.

sendgrid is also a great option, I think it has the same limitation
has gmail (200 email out per day?), but its faster (at least for me)
and its nicely integrated with Heroku

> > >>> refinery-cms...@googlegroups.com<refinery-cms%2Bunsubscribe@google groups.com>

Philip Arndt

unread,
Apr 6, 2010, 6:04:45 PM4/6/10
to refine...@googlegroups.com
+1 SendGrid

By default Refinery tries to send from no-r...@your-domain.com but we could support overriding that with a RefinerySetting ?

giorgio

unread,
Apr 7, 2010, 6:53:53 AM4/7/10
to Refinery CMS
Thanks for all the replies.

The story is that the ":enable_starttls_auto => true" setting only
works in ruby 1.8.7 and rails >= 2.2.1
On my dev machine I had 1.8.7 and 2.3.5

I put the following into /initializers/smtp_gmail.rb:


ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {

:enable_starttls_auto => true,


:address => "smtp.gmail.com" ,
:port=>587,
:authentication => :plain ,

:domain => "mydomain.com" ,
:user_name => "sup...@mydomain.com" ,
:password => "mypassword"
}

I also changed the "From" email address as suggested by rafael.
However you don't seem to be able to use something like "Bertie
<ber...@gmail.com>" because you get a syntax error when sending.
This appears to boil down to the system wrapping the From address with
<> brackets.
The work around is to simply have the email address with no name in
the "From". If anyone knows a way around this it would be good.

To get the mail working like this on Heroku I then had to "migrate"
the app to 1.8.7 as Heroku default is 1.8.6
<heroku stack:migrate bamboo-ree-1.8.7>

The refinery app worked after adding an extra gem to the Gemfile:
gem "aws-s3", ">= 0.5.1", :require => "aws-s3"

I hope that may help somebody else out with getting their mail going.

Cheers
George

Jesper Hvirring Henriksen

unread,
Apr 7, 2010, 8:00:25 AM4/7/10
to refine...@googlegroups.com
On 06/04/2010, at 23.13, giorgio wrote:

> I will check out that hard coding in the inquiries gem. I wonderered
> if that was the case as it always tried to send from no-
> re...@heroku.com.

It sends from "no-reply@domain", so if your app is running as your-app.heroku.com, Refinery will send from no-r...@heroku.com.

If you run your app on Heroku using a custom domain, it will use that just fine.

A quick fix would be to change your tld_length in settings to 2, which will make the from address no-r...@your-app.heroku.com

/Jesper

Reply all
Reply to author
Forward
0 new messages