Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Message
- include ActiveAttr::Model
- include ActiveModel::Validations
- attribute :name
- attribute :email
- attribute :subject
- attribute :body
- attr_accessible :name, :email, :subject, :body
- validates_presence_of :name
- validates_presence_of :email
- validates :email, email_format: { message: "is not looking like a valid email address"}
- validates_presence_of :subject
- validates_length_of :body, maximum: 500
- end
- class ContactForm < ActionMailer::Base
- default from: "myemail@gmail.com"
- default to: "myemail@gmail.com"
- def email_form(message)
- @message = message
- mail subject: "#{message.subject} #{message.name}"
- mail body: "#{message.body}"
- end
- end
- config.action_mailer.delivery_method = :smtp
- config.action_mailer.perform_deliveries = true
- config.action_mailer.smtp_settings = {
- :address => "smtp.gmail.com",
- :port => 587,
- :domain => "mydomain.com",
- :user_name => "myemail@gmail.com",
- :password => "mypassword",
- :authentication => :plain,
- :enable_starttls_auto => true
- }
- config.action_mailer.default_url_options = {
- :host => "localhost:3000"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement