0
votes

Ok, i'm a total newbie so please forgive me in advance.

I want to create a very simple rails application. I've created a button that's supposed to send an email to myself. I've had no previous Rails experience so any help you can give is much appreciated.

Here's what I've done so far:

config/environment.rb:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => 'baci.lindsaar.net',
  :user_name            => 'myUsernameHere',
  :password             => 'myPassHere',
  :authentication       => 'plain',
  :enable_starttls_auto => true  }

controllers/posts_controller.rb:

 def sendMessage
     UserMailer.welcome_email().deliver
     respond_to do |format|
         format.html { render :nothing => true, :status => :ok } 
     end
 end

app/mailers/user_mailer.rb:

class UserMailer < ActionMailer::Base

def welcome_email()
    mail(:to => '<my email address here>',
          :subject => "Welcome to My Site")
    end
end

I've also created the email template in views/user_mailer/welcome_email.html.erb

The problem: I click on the button and I don't receive an email.

Thank you very much in advance.

Matt

2

2 Answers

0
votes

In MycontrollerController send_mail is action so this is wrong def send_email(address) just define

def send_email(address)
  @address = params[:address]
  PostMailer.test_email(@address).deliver
 end

I think that is what the above error is

0
votes

nevermind, i was forgettting

default :from => "<email address here>"

in app/mailers/user_mailer.rb

it works now.