# Strange issue iwth sending smtp with gmail

**URL:** <https://www.ruby-forum.com/t/strange-issue-iwth-sending-smtp-with-gmail/124024>\
**Category:** Ruby\
**Created:** [December 23, 2007, 6:25pm UTC](https://www.ruby-forum.com/t/strange-issue-iwth-sending-smtp-with-gmail/124024 "2007-12-23T18:25:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 23, 2007, 6:25pm UTC](https://www.ruby-forum.com/t/strange-issue-iwth-sending-smtp-with-gmail/124024/1 "2007-12-23T18:25:33Z")

</div>

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](http://smtp.example.com)”,

# :domain =\> “[example.com](http://example.com)”}

class GmailMailer \< ActionMailer::Base  
ActionMailer::Base.smtp\_settings = {  
:address =\> “[smtp.gmail.com](http://smtp.gmail.com)”,  
:port =\> 587,  
:authentication =\> :plain,  
:user\_name =\> “removed\_email\_address@domain.invalid”,  
: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(“removed\_email\_address@domain.invalid”,“removed\_email\_address@domain.invalid”,“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” ,“removed\_email\_address@domain.invalid”," "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

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 23, 2007, 7:15pm UTC](https://www.ruby-forum.com/t/strange-issue-iwth-sending-smtp-with-gmail/124024/2 "2007-12-23T19:15:57Z")

</div>

On Dec 23, 12:21 pm, Junkone [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> #{:address =\> “[smtp.example.com](http://smtp.example.com)”,  
> def sendmsg(to, sender, subj, content, strip\_ext = true)  
> #attachment :content\_type =\> content\_type,  
> class  
> from e:/ruby/lib/ruby/1.8/net/smtp.rb:545:in `each' 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

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [December 24, 2007, 6:34am UTC](https://www.ruby-forum.com/t/strange-issue-iwth-sending-smtp-with-gmail/124024/3 "2007-12-24T06:34:20Z")

</div>

On Mon, 24 Dec 2007 03:14:58 +0900, Junkone wrote:

> ignorethis post.

Not at all, it was quite interesting and gives food for thought 🙂

-Thufir
