Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sending an email via Pony mail with no authentication?

Tags:

ruby

I want to send an email from my ruby script using Pony mail. When I set it up for gmail smtp it works fine. When I set it up to use our ISP's SMPT I get this error.

I was told by iiNet representative that no authentication is needed. When I send email from command line using mail command it works nicely. Or even when sending email using telnet mail.iinet.com.au 25 no authentication is required.

/usr/lib64/ruby/1.8/net/smtp.rb:777:in check_auth_args': SMTP-AUTH requested but missing secret phrase (ArgumentError)

for settings

  Pony.mail(:to => '[email protected]', 
        :from => '[email protected]',
            :subject => 'overnight testing results', 
            :body => results, 
            :via => :smtp, 
            :via_options => {
               #:openssl_verify_mode => OpenSSL::SSL::VERIFY_NONE,
               :address     => 'mail.iinet.com.au',
               :port     => '25',
               #:enable_starttls_auto => true,
               #:user_name     => '[email protected]',
               #:password => '1234',
               :authentication     => :plain,           # :plain, :login, :cram_md5, no auth by default
                :domain               => "localhost.localdomain" # the HELO domain provided by the client to the server
                                                     }
) 

conf

  • ruby 1.8.7 (2010-01-10 patchlevel (249) [x86_64-linux]
  • mail (2.3.0)
  • mime-types (1.16)
  • pony (1.2)

update I

if I do telnet mail.iinet.com.au 25 with below commands the email is sent and received. No authentication required.

mail from: from@address
rcpt to: to@address
data
from: from@address
to: to@address
subject: subject line
message body
.
like image 230
Radek Avatar asked Jun 07 '11 00:06

Radek


3 Answers

You are specifying that you want to perform authentication. Remove the line that says :authentication => :plain

like image 144
cam Avatar answered Nov 14 '22 09:11

cam


This works like a charm for me:

require 'pony'

Pony.mail(
  :to => 'xxx', 
  :from => 'xxx',
  :subject => 'test', 
  :body => "test", 
  :via => :smtp, 
  :via_options => {
      :address     => 'xxx',
      :port     => '25',
    }
)

obviously you need to replace these "xxx" with real values

like image 21
Schmurfy Avatar answered Nov 14 '22 09:11

Schmurfy


I posted a question to ponyrb group and the solution is to use enable_starttls_auto => false

so the final working code for me is

Pony.mail(
  :to => '[email protected]', 
  :from => '[email protected]',
  :subject => 'test', 
  :body => "test pony", 
  :via => :smtp, 
  :via_options => {
      :address     => 'mail.iinet.com.au',
      :port     => '25',
      :enable_starttls_auto => false
    }
)
like image 36
Radek Avatar answered Nov 14 '22 10:11

Radek