Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7028277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:21:58+00:00 2026-05-28T00:21:58+00:00

I worked through some basic tutorials on Rails 3. The goal is a community-website

  • 0

I worked through some basic tutorials on Rails 3. The goal is a community-website on abilities and activities. I am using Devise for authentication. The creation of user profiles with avatars worked well (thanks to paperclip).

As a next step, I want to enable registered users to send an e-mail to a user from his (or her) profile page. I found a great tutorial on creating a contact form using Google Apps:
http://matharvard.ca/posts/2011/aug/22/contact-form-in-rails-3/

The mailer class in this tutorial looks like:

class NotificationsMailer < ActionMailer::Base

  default :from => "noreply@youdomain.dev"
  default :to => "you@youremail.dev"

  def new_message(message)
    @message = message
    mail(:subject => "[YourWebsite.tld] #{message.subject}")
  end

end

My question: What is the best way to replace you@youremail.dev with the receivers E-Mail-Address? (from the User-Model)

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:21:59+00:00Added an answer on May 28, 2026 at 12:21 am

    You can modify the new_message to accept the user (or list of users) to whom you want to send the email. Or an array of email addresses if you want to. Then pass the receiver’s email address to the mail method as the :to option.

    def new_message(receiver, message)
      @message = message
      mail(:subject => "[YourWebsite.tld] #{message.subject}",
           :to => receiver.email_address) # or something similar
    end
    

    Then you can invoke your mailer like this

    NotificationEmail.new_message(a_user, a_message).deliver
    

    To read the API see here or here (I prefer APIdock).

    Also a more comprehensive guide on ActionMailer is available here. If you are new to Rails, you can find more guides here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having worked through some tutorials on some basics via the iPhone, I'm struggling to
Although I'm following backbone.js for some months and worked through a plethora of tutorials,
I've worked myself through the rapidXML sources and managed to read some values. Now
I had some code that ran commands through Runtime.getRuntime.exec(String) , and it worked on
new to IOS OpenGL programming. I have worked through a few tutorials that talk
Sticking my toe into the Silverlight/Blend pool, I've worked through some very cool video
I just worked through a book on WCF and was surprised that it didn't
I'm new to Workflow Foundation. I've worked my way through one book (K. Scott
I've worked on a few projects managed through the use of a Gantt chart.
I want to iterate through all 5 character combinations of 0-9, a-z. I worked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.