Forum: Ruby on Rails Action Mailer - connection refused - connect(2)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bruce B. (Guest)
on 2005-12-15 20:46
(Received via mailing list)

I am on Mac OSX 10.4 using locomotive.

My ActionMailer configuration is

ActionMailer::Base.delivery_method = :smtp  # or :sendmail or test
ActionMailer::Base.server_settings = {
   :address            =>  "",
   :port               =>  25,
   :domain             =>  ""
ActionMailer::Base.perform_deliveries = true   # alternative was false
ActionMailer::Base.default_charset = "utf-8"

I have created the mail successfully because I can display it in my
browser. But when I try to send it I get this error:

Errno::ECONNREFUSED in Events#send_my_email

Connection refused - connect(2)

My mail account does not require authentication.

I also tried using the sendmail option but got the same error. I also
tried a different mail account I have (dot mac) and received the same

Any ideas where I should begin looking?

Lou V. (Guest)
on 2005-12-15 22:56
(Received via mailing list)
you may need to specify 3 more server settings:

:user_name -- If your mail server requires authentication, set the
username in this setting.
:password -- If your mail server requires authentication, set the
password in this setting.
:authentication -- :login is common

Also, your mail server's address my be something like
you may want to call your tech support/ISP and find out what all the
params should be.
Bruce B. (Guest)
on 2005-12-15 23:54
(Received via mailing list)

Thanks for taking the time to write.

I have written to my ISP but I doubt that is the problem since I have
tried it from sendmail and from another mailserver (my dot mac
account). Whatever I do and whoever I connect to, I get the same
connection error.

Any more ideas?

Lou V. (Guest)
on 2005-12-16 00:21
(Received via mailing list)
telnet 25

doing this will verify the mail server is accessible
(you should see a one-line message saying something about which
mail service is available).

then you just need to figure out what the remaining authentication
parameters are, if no other way but trail and error if your ISP
isn't helping.

here's another email test script:

#!/bin/env ruby

# This is used to send email.
require 'net/smtp'

	# Helper method.
	# Append _appendage_ to end of string if it already doesn't exist
	# at the end of the string.
	class String #:nodoc:
		def appendIfMissing(appendage)
			return self if appendage.nil? || appendage.size < 1
			return appendage if size < 1
			if self[-appendage.size..-1] == appendage
				self + appendage

	class String #:nodoc:
	  def blank?
		empty? || strip.empty?

	# Print an error message.
	def err(msg, printRubyErr=false, fatal=true) #:nodoc:
		STDERR.print "\n### ERROR: #{msg}\n\n"
		STDERR.print "\n#{$!}\n\n" if printRubyErr
		exit if fatal
		"### ERROR: #{msg}\n#{$!}\n"

	# simple check of email address.
	def checkMailAddress(address, descr) #:nodoc:
		addr = address[/<?\w+@\w+\.\w+>?$/]
		if addr.blank?
			return nil

	# Send email.
	def mail( od )
		# The email is composed of the 'From', 'To', and 'Subject' fields,
followed by the body text.
		# Strip off leading white space.
		(msgstr = <<END_OF_MAIL_MESSAGE).gsub!(/^\s+/, '')
			From:    #{od['-=']}
			To:      #{od['-t']}
			Subject: #{od['-j'].blank? ? 'No Subject' : od['-j']}


		msgstr += od['-b']

		return if (addr_from = checkMailAddress(od['-='], "no 'From' address
(#{od['-=']})") ).nil?
		return if (addr_to   = checkMailAddress(od['-t'], "no 'To' address
(#{od['-t']})") ).nil?

		# The email is actually sent here.
			Net::SMTP.start(od['-m'], 25, od['-n'], od['-S'], od['-P'], :login) {
			  smtp.send_message msgstr, addr_from, addr_to

			puts "-- mail sent to #{addr_to}" if od['-V']
		rescue Exception => ex
			err("unable to send mail.\n#{msgstr}\n#{$!}\naddr
from:#{addr_from}\naddr to:#{addr_to}", true)
	end # mail

	od = {  '-=' => 'My Long Name<removed_email_address@domain.invalid>', # mail 
		'-t' => 'My Long Name<removed_email_address@domain.invalid>', # mail to
		'-j' => 'This is a test',		# mail subject
		'-b' => 'Body text of the email.',	# mail body text
		'-m' => '',			# mail server
		'-n' => '',			# domain sending mail from
		'-S' => 'mailusername',			# mail user name
		'-P' => 'super_secret_password',	# mail password
		'-V' => true }

	mail od
Bruce B. (Guest)
on 2005-12-16 03:47
(Received via mailing list)
thanks, lou

Bruce B. (Guest)
on 2005-12-16 17:45
(Received via mailing list)

Apologies for my persistence.

I telnetted in, as you suggested, but all was well.  I tried sendmail
and 3 different ISPs but I always receive an identical error.  I had
one of my ISPs (fortunately, a friend of mine) sit and watch his logs
while I attempted to send the email.  He tells me that my machine
never contacted his machine.

So, can we go down a different avenue? Are you aware of any other
cause of this error?

This topic is locked and can not be replied to.