Diego
Diego

Reputation: 37

Send email after user registration in rails 4.0

I want to send me a email after a user register with his information but I get this error:

SyntaxError (/mailers/user_mailer.rb:6: invalid multibyte char (US-ASCII)
C:/Sites/dc/app/mailers/user_mailer.rb:6: syntax error, unexpected $end
    mail(to: email, subject: 'Welcome to My Awesome Site')
 ^):
  app/models/user.rb:24:in `enviar_mail_activado'

I have this class mailer

class UserMailer < ActionMailer::Base

  default from: "[email protected]"

  def welcome_message()
    mail(to: '[email protected]', subject: 'Welcome to My Awesome Site')
  end
end

Then in my User model an after_save filter and this method:

def enviar_mail_activado
    UserMailer.welcome_message().deliver    
end

And my environment.rb

ActionMailer::Base.smtp_settings = {
  :address        => 'smtp.gmail.com',
  :domain         => 'mail.google.com',
  :port           => 587,
  :user_name      => '[email protected]',
  :password       => 'xxxxx',
  :authentication => :plain,
  :enable_starttls_auto => true
}

Why i have that error? Its show me in the log not at the site.

Upvotes: 0

Views: 75

Answers (1)

wspruijt
wspruijt

Reputation: 1067

Seem like you're using some non-ascii character in the user_mailer.rb.

Add # encoding: utf-8 to the beginning of the file.

Upvotes: 1

Related Questions