SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with contact form

    I'm brand new to rails. I'm jumping right in with an existing app.

    So, in app/models, I have contact_mailer.db

    Looks like this:
    Code:
    class ContactMailer < ActionMailer::Base
    
      def validate_email(sendto, url)
        @recipients      = sendto
        @from            = "noreply@floridainternationalhomes.com"
        @subject         = "Confirm Your Email Address"
        @body["url"]     = url
        @sent_on         = Time.now
        @headers         = {}
      end
    
      def notify(contact)
        @recipients      = "me@domain{dot}com"
        @from            = "noreply@domain{dot}com"
        @subject         = "Contact from Website"
        @body["contact"] = contact
        @headers         = {}
      end
    
    end
    In app/controllers/website_controller.rb I have this and it works:

    Code:
    wr = WebsiteRequest.new(params[:wr])
        
    if wr.save
          id  = wr.id
          id  = Base64.b64encode("#{wr.id}")
          url = url_for(
              :controller => "website",
              :action     => "email_confirmed",
              :id         => id)
    		
          email = ContactMailer.create_validate_email("#{wr.email}",url)
          ContactMailer.deliver(email)
        
         ...
        
    end
    But instead of using the validate_email method, which sends an email to the person who filled out the form, I want to send it to myself. I've tried this and it doesn't work:

    Code:
    email = ContactMailer.create_notify('This is the body of the email')
    ContactMailer.deliver(email)
    I've tried different things and I can't seem to get it. I've also tried calling ContactMailer.notify('Body') and that didn't work either.

    Any ideas? Seems like a simple thing but I just can't get it.
    My website: www.sitehatchery.com

    Recent Article: Dynamic CSS

  2. #2
    SitePoint Addict
    Join Date
    Feb 2007
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By "doesn't work" I'm assuming you mean doesn't send an email.

    What environment (production or development) are you in? Did you set up the Actionmailer settings properly?

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That, and I get a general script-generated application error message. Can't find the exact error in a log file. Is there a way for me to print the error to the screen?

    I'm in mongrel rails. The actionmailer settings were already set up when I arrived on the scene. It already sends the confirmation email to the user, so I know it works. I'm trying to get it to send the user input to admin in the form of an email.
    My website: www.sitehatchery.com

    Recent Article: Dynamic CSS


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •