Hi.
I’m working on sending mails issue and I have one question:
How can it be possible for my application to be sending emails, without
configuring mail server specific parameters (domain name, username,
password, etc)?
Does anyone have an answer on this?
Here is the code in the controller:
def send_email
Notifier.deliver_signup_notification(“[email protected]”)
end
And, here it is the class:
class Notifier < ActionMailer::Base
def signup_notification(myEmail)
recipients myEmail
subject “Test Subject”
body “Test body”
from “[email protected]”
content_type “text/html”
end
end
Thanks in advance.
Regards,
Sase
P.S. I am new at this, so excuse me if I’m sending silly questions, but
I’m trying to learn how stuff works
I’m working on sending mails issue and I have one question:
How can it be possible for my application to be sending emails,
without
configuring mail server specific parameters (domain name, username,
password, etc)?
Does anyone have an answer on this?
Here is the code in the controller:
Because you do need to provide these parameters, but I place them in
environment.rb (or a specific production/development environment if
they differ).
Using Sendmail
ActionMailer::Base.delivery_method = :sendmail
Or normal SMTP
ActionMailer::Base.smtp_settings = {
:address => “127.0.0.1”,
:domain => “mydomain.com”,
:port => 123456789,
:user_name => “myuser”,
:password => “mypassword”,
:authentication => :plain/:login/:cram_md5 (whatever you want to
use of these three)
}
Hi Peter,
First of all, thanks for the quick reply :)))
If understood correctly, I either use :sendmail or SMTP settings.
My code worked with
config.action_mailer.delivery_method = :smtp
in the Rails::Initializer.run block situated in the environment.rb
and (as you said)
ActionMailer::Base.delivery_method = :sendmail.
If I remove these two lines in the environment.rb, that means that I
should write SMTP parameters, right?
Well, I’m using WEBrick, but I’ve restarted it for sure.
I really don’t know what’s wrong with this
Usually, we all want the code to work, but now I don’t want to :))
Can you suggest some tutorial so I can read something meanwhile?
I have few tutorials, but anything + is welcomed
So now my environment.rb file looks like this (no SMTP, no Sendmail):
RAILS_GEM_VERSION = ‘1.2.3’ unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(FILE), ‘boot’)
Rails::Initializer.run do |config|
end
But, it STILL sends mails.
Is this ok???
Did you restart your mongrel(s)? Environment is loaded at startup. If
you don’t want to send mails in development, there’s a parameter in
the environment variables for that too.
If SMTP server is not specified in environment.rb or helper,
ActionMailer defaults to localhost’s smtp agent. That’s why the email
still gets sent out. There aren’t too many up to date tutorials out
there and with ActionMailer, I found too many subtle changes from
versions.
Agile Web D. with Rails, Second Edition, buy the PDF version
and you’ll have all the info you need a few minutes later. You should
also check the wiki (and hope the info isn’t outdated): http:// wiki.rubyonrails.org/rails/pages/ActionMailer
Great!
Thanks Peter…
I’m about to read this book, and if I have any question, I’ll ask you
guys…
Thanks again!
Well, I’m using WEBrick, but I’ve restarted it for sure.
I really don’t know what’s wrong with this
Usually, we all want the code to work, but now I don’t want to :))
Can you suggest some tutorial so I can read something meanwhile?
I have few tutorials, but anything + is welcomed
Agile Web D. with Rails, Second Edition, buy the PDF version
and you’ll have all the info you need a few minutes later. You should
also check the wiki (and hope the info isn’t outdated): http:// wiki.rubyonrails.org/rails/pages/ActionMailer
If SMTP server is not specified in environment.rb or helper,
ActionMailer defaults to localhost’s smtp agent. That’s why the email
still gets sent out. There aren’t too many up to date tutorials out
there and with ActionMailer, I found too many subtle changes from
versions.
if you are on textdrive you can send emails without configuring
anything.
Hi Hasham,
I’m afraid I’m not using textdrive, but still thanks for your concern
I guess I’ll have to stick to the ‘ActionMailer defaults to localhost’s
smtp agent’ till I read some tutorials and make things clear.
Thanks again!
Regards,
Sase
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.