how to send a mail using ruby..?plz help me

Recommended Answers

All 2 Replies

how to send a mail using ruby..?plz help me

quick example using action_mailer.

If you don't have it already gem install 'action_mailer'

require 'action_mailer'

ActionMailer::Base.server_settings = {
  :address => "your.smtp.server",
  :port => 25, 
  :domain => 'yourdomain',
  :user_name => "your_user_name",
  :password => "shhhsecret",
  :authentication => :login
} 

class Emailer < ActionMailer::Base
  def test_email(user_email)
    subject    "Free C1Alis"
    from       "system@example.com"
    recipients user_email.address
    body	"Get large, #{user_email.name}!"
  end
end

@email_addresses = [ { :name => "Bobby Ewing", :address => "bobby@dallas.com" }, { :name => "Ewing, JR", :address => "jr@dallas.com" } ]

@email_addresses.each do |e|
	Emailer.deliver_test_email(e)
end
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.