can anyone tell me abt
how to include email option in ror application.
with code
plz
can anyone tell me abt
how to include email option in ror application.
with code
plz
Nagesh S. wrote:
can anyone tell me abt
how to include email option in ror application.
with code
plz
you generate a model that is derived from ActionMailer, and via that
class, you send mails. something like this
===================
ruby script generate mailer MAILERNAME
===================
in the models/MAILERNAME.rb file you’ll find:
class MAILERNAME < ActionMailer::BASE
#you need to define here a method to send emails:
def some_email
#here you put all of the headers of the email:
@recipients = “[email protected]”
@from = “from Nagesh”
@subject = “title of my email”
@content-type ‘text/html’
@body[“variable”] = 123
end
end
=================
now you need to write the email to send; this is in the views/MAILERNAME
folder - the name of the template is the name of the method you defined
in the model, so in our case it would be:
views/MAILERNAME/some_email.rhtml
Hi, this is the email being sent… and what is here: “<%= @variable %>”
should equal to ‘123’!
==================
now that you’ve set up the files, you need to send the email out: here’s
how to do that, in the controller:
…
…
def some_method
…
…
#here:
MAILERNAME::deliver_some_email
#when you write down deliver_* you are basically sending the email out
something like this:
ActionMailer::Base.server_settings = {
:address => “localhost”,
:domain => ‘www.yourdomain.com’,
:port => 25
}
(you need to configure this to your settings)
and try it on production - it may not work in development mode.
=========
that’s it, really. here’s some good documentation on the subject:
http://api.rubyonrails.org/files/vendor/rails/actionmailer/README.html
=======
–shai
is necessary to install stmp server in my system …
On 23 Jul 2007, at 14:15, Nagesh S. wrote:
is necessary to install stmp server in my system …
Either install your own or use your ISPs or hosting company’s SMTP
server.
Best regards
Peter De Berdt
HI i am presently new to this ror language can you please send me the
stepwise procedure for sending the email …
On 23 Jul 2007, at 14:59, Nagesh S. wrote:
HI i am presently new to this ror language can you please send me the
stepwise procedure for sending the email …
http://wiki.rubyonrails.org/rails/pages/HowToSendEmailsWithActionMailer
Or even better: buy the Agile Web D. with RoR book at http://
pragmaticprogrammer.com/titles/rails/
Best regards
Peter De Berdt
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.smtp_settings = {
:address => “smtp.postoffice.net”,
:port => 25,
:domain => ‘www.mywebsite.com’,
:user_name => “[email protected]”,
:password => ‘mypass’,
:authentication => :login
}
But it is not working can any modifications necessary…
class EmailerController < ApplicationController
def sendmail
email = @params[“email”]
recipient = email[recipient]
subject = email[subject]
message = email[message]
Emailer.deliver_contact(recipient, subject, message)
return if request.xhr?
render :text => ‘Sucessfully sent a mail…’
end
def index
render :file => ‘app\views\emailer\index.rhtml’
end
end
class Emailer < ActionMailer::Base
def contact(recipient, subject, message, sent_at = Time.now)
@subject = subject
@recipients = recipient
@from = ‘[email protected]’
@sent_on = sent_at
@body[“title”] = ‘This is title’
@body[“email”] = ‘[email protected]’
@body[“message”] = message
@headers = {}
end
end
ActionMailer::Base.delivery_method =:sendmail
ActionMailer::Base.server_settings = {
:address => “localhost”,
:port => 25,
:domain => “gmail.com”,
:authentication => :login,
:user_name => “username”,
:password => "password
}
Hi!
You are having one email message from <%= @email %> with a tilte
<%= @title %>
and following is the message:
<%= @message %>
Thanks
Subject: <%= text_field 'email', 'subject' %>
Recipient: <%= text_field 'email', 'recipient' %>
Message
<%= text_area 'email', 'message' %>
but still i cannot able to send the mails… what are the changes
required please kindly send me code…
On 23 Jul 2007, at 15:16, Nagesh S. wrote:
}
You either use sendmail or smtp:
ActionMailer::Base.delivery_method =:smtp
Best regards
Peter De Berdt
In addition to the other pointers. Ryan Davies has just done a
screencast
on this topic
On 23 Jul 2007, at 15:35, Nagesh S. wrote:
i had kept this also but i cnot able to send email:
can you provide me a stepwise procedure for sending email:
ActionMailer::Base.delivery_method =:smtp
There’s no more to it, you’ll have to use your common sense and the
log files to find out what goes wrong.
Best regards
Peter De Berdt
i had kept this also but i cnot able to send email:
can you provide me a stepwise procedure for sending email:
ActionMailer::Base.delivery_method =:smtp
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs