strange issue iwth sending smtp with gmail

J

Junkone

Hello
When i use this class and execute it, it works fine. i am able to send
email thro gmail. however it does not work if i call this method from
another class. i get a smtp error. dunno what the reasons are. i am
attaching the working file and not working file.


require "action_mailer"
require "smtp_tls"

#ActionMailer::Base.smtp_settings =
#{:address => "smtp.example.com",
# :domain => "example.com"}




class GmailMailer < ActionMailer::Base
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:user_name => "(e-mail address removed)",
:password => "password"
}
def sendmsg(to, sender, subj, content, strip_ext = true)


#standard ActionMailer message setup
recipients to
from sender
subject subj
#setting the body explicitly means we don't have to provide a
separate template file
body content

##set up the attachment
#attachment :content_type => content_type,
# :body => File.read(file_name),
# :filename => file_name.gsub(/.*\//,'')
end
end
GmailMailer.deliver_sendmsg("(e-mail address removed)","(e-mail address removed)","hello
this is a test","this is a body")
# The above class works as long as the GmailMailer.deliver is called
with thin the fine.

However the following does not work at all if i call it from another
class
GmailMailer.deliver_sendmsg( "another email
address" ,"(e-mail address removed)"," "sometext ","some more text")
I get the following error.
e:/ruby/lib/ruby/site_ruby/1.8/xmlconfigfile.rb:646: warning:
parenthesize argument(s) for future version
e:/ruby/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 555 5.5.2
Syntax error n63sm12043118pyh.5 (Net::SMTPFatalError)
from e:/ruby/lib/ruby/1.8/net/smtp.rb:653:in `getok'
from e:/ruby/lib/ruby/1.8/net/smtp.rb:635:in `rcptto'
from e:/ruby/lib/ruby/1.8/net/smtp.rb:546:in `send0'
from e:/ruby/lib/ruby/1.8/net/smtp.rb:545:in `each'
from e:/ruby/lib/ruby/1.8/net/smtp.rb:545:in `send0'
from e:/ruby/lib/ruby/1.8/net/smtp.rb:472:in `sendmail'
from e:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/
action_mailer/base.rb:567:in `perform_delivery_smtp'
from e:/ruby/lib/ruby/1.8/net/smtp.rb:379:in `start'
from e:/ruby/lib/ruby/1.8/net/smtp.rb:316:in `start'
from e:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/
action_mailer/base.rb:565:in `perform_delivery_smtp'
from e:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/
action_mailer/base.rb:451:in `send'
from e:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/
action_mailer/base.rb:451:in `deliver!'
from e:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/
action_mailer/base.rb:333:in `method_missing'
from E:/TradingTools/CODE/scanForex.rb:46
 
J

Junkone

Hello
When i use this class and execute it, it works fine. i am able to send
email thro gmail. however it does not work if i call this method from
another class. i get a smtp error. dunno what the reasons are. i am
attaching the working file and not working file.

require "action_mailer"
require "smtp_tls"

#ActionMailer::Base.smtp_settings =
#{:address => "smtp.example.com",
# :domain  => "example.com"}

class GmailMailer < ActionMailer::Base
    ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:user_name => "(e-mail address removed)",
:password => "password"
    }
  def sendmsg(to, sender, subj, content, strip_ext = true)

    #standard ActionMailer message setup
    recipients  to
    from        sender
    subject     subj
    #setting the body explicitly means we don't have to provide a
separate template file
    body        content

    ##set up the attachment
    #attachment  :content_type => content_type,
    #            :body         => File.read(file_name),
    #            :filename     => file_name.gsub(/.*\//,'')
  end
end
GmailMailer.deliver_sendmsg("(e-mail address removed)","(e-mail address removed)","hello
this is a test","this is a body")
# The above class works as long as the GmailMailer.deliver is called
with thin the fine.

However the following does not work at all if i call it from another
class
GmailMailer.deliver_sendmsg( "another email
address" ,"(e-mail address removed)"," "sometext ","some more text")
I get the following error.
e:/ruby/lib/ruby/site_ruby/1.8/xmlconfigfile.rb:646: warning:
parenthesize argument(s) for future version
e:/ruby/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 555 5.5.2
Syntax error n63sm12043118pyh.5 (Net::SMTPFatalError)
        from e:/ruby/lib/ruby/1.8/net/smtp.rb:653:in `getok'
        from e:/ruby/lib/ruby/1.8/net/smtp.rb:635:in `rcptto'
        from e:/ruby/lib/ruby/1.8/net/smtp.rb:546:in `send0'
        from e:/ruby/lib/ruby/1.8/net/smtp.rb:545:in `each'
        from e:/ruby/lib/ruby/1.8/net/smtp.rb:545:in `send0'
        from e:/ruby/lib/ruby/1.8/net/smtp.rb:472:in `sendmail'
        from e:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/
action_mailer/base.rb:567:in `perform_delivery_smtp'
        from e:/ruby/lib/ruby/1.8/net/smtp.rb:379:in `start'
        from e:/ruby/lib/ruby/1.8/net/smtp.rb:316:in `start'
        from e:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/
action_mailer/base.rb:565:in `perform_delivery_smtp'
        from e:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/
action_mailer/base.rb:451:in `send'
        from e:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/
action_mailer/base.rb:451:in `deliver!'
        from e:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/
action_mailer/base.rb:333:in `method_missing'
        from E:/TradingTools/CODE/scanForex.rb:46

ignorethis post. this actually works. i had a nil email id to send
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top