ActionMailer issue

Hi. :slight_smile:
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 :wink:

Hi,
Me again.
This code works properly, but I don’t know why :frowning:

Sase

On 03 Jul 2007, at 13:34, Sase wrote:

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)
}

Best regards

Peter De Berdt

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?

Regards,
Sase

On 03 Jul 2007, at 14:15, Sase wrote:

If understood correctly, I either use :sendmail or SMTP settings.

Correct

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)

One of the two notations is the preferred one, don’t remember which one.

ActionMailer::Base.delivery_method = :sendmail.

I place this below the Rails::Initializer block.

If I remove these two lines in the environment.rb, that means that I
should write SMTP parameters, right?

Probably yeah. Just try it out :slight_smile:

Best regards

Peter De Berdt

Hi.
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???

Regards,
Sase

Well, I’m using WEBrick, but I’ve restarted it for sure.
I really don’t know what’s wrong with this :frowning:
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 :slight_smile:

Thanks once again!

Regards,
Sase

On 03 Jul 2007, at 14:33, Sase wrote:

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.

Best regards

Peter De Berdt

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.

Good luck!

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!

Regards,
Sase

On 03 Jul 2007, at 14:47, Sase wrote:

Well, I’m using WEBrick, but I’ve restarted it for sure.
I really don’t know what’s wrong with this :frowning:
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 :slight_smile:

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

Best regards

Peter De Berdt

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.

Ahaaaa… :slight_smile:
Now I get it :wink:

Thanks Joon for your reply!

Regards,
Sase

if you are on textdrive you can send emails without configuring
anything.

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
:wink:
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