[ACCEPTED]-send email from localhost-localhost

Accepted answer
Score: 31

Update for rails 4.0
Now you need these 1 code to make it work:

# I recommend using this line to show error
config.action_mailer.raise_delivery_errors = true

ActionMailer::Base.smtp_settings = {
  :address        => 'smtp.gmail.com',
  :domain         => 'mail.google.com',
  :port           => 587,
  :user_name      => 'foo@gmail.com',
  :password       => '******',
  :authentication => :plain,
  :enable_starttls_auto => true
Score: 16

You can set up ActionMailer to use Gmail's 3 SMTP server using something like this in 2 config/environment.rb:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.server_settings = {
    :address        => 'smtp.gmail.com',
    :domain         => '<your domain>',
    :port           => 587,
    :user_name      => '<your gmail>',
    :password       => '<your password>',
    :authentication => :plain

Edit: If you experience any difficulties, set 1 your config to display errors:

ActionMailer::Base.raise_delivery_errors = true
Score: 5

Have a look at ActionMailer. In RAILS_ROOT/config/environment/ , there is a file for 5 different environments (development, test, production) the 4 configurable settings go in these files

You 3 specify the delivery_method like this,

ActionMailer::Base.delivery_method = :sendmail

or 2 if you want

ActionMailer::Base.delivery_method = :smtp

A detailed example of the settings 1 has been posted by Mikael S


Score: 4

If I understand your situation correctly, you 23 want to send an email from your local computer 22 using a custom email address such as john@mycompany.com. If 21 you already registered the domain name for 20 your email account ( mycompany.com ) is 19 very likely that the company that is hosting 18 your website, also has a POP/SMTP server. If 17 so, you can use Mikael S's sample and change 16 the address parameter to your Hosting company's 15 smtp address and use your hosting company's 14 username/password.

If you have not register 13 your custom domain or don't have a hosting 12 provider, you can install a free email server 11 in your local computer. If you use WindowsXP, you 10 can add the IIS email server by going to 9 add/remove programs->windows features. If 8 you are using Linux, you can use any of 7 the email servers available in the repositories. Once 6 you install your local email server you 5 will use Mikael S's sample code and use 4 or localhost in the address field. If 3 you are using WindowsXP's email server, I 2 think you don't have to enter username/password.

Hope 1 it helps you.

More Related questions