net/smtp

D

Dave Lilley

I am not sure if I've properly understood things correctly but....

I am trying to emulate sample code in the RDOC's of ruby core.
can some one assist?

Error is...
/barcode_class_rpt_email.rb:199:in `send_email': wrong number of
arguments (5 for 4) (ArgumentError)

code that generate this is this...

require 'sendemail'

def init
@email = Sendemail.new

lots of code between and in a fxruby class (don't know if this is an
issue).

198 uname.each do |receipiant|
199 @email.send_email(@sender,receipiant, 'Automatic Patrol
Report', @msg, @server)
end

the called script (it is referenced correctly).

# sendemail.rb
require 'net/smtp'

class Sendemail
def send_email(from, to, subject, message, server)

Net::SMTP.start("#{server}", 25) do |smtp|
smtp.set_debug_output $stdout

smtp.open_message_stream("#{from}", "#{to}") do |f|
f.puts "From: #{from}"
f.puts "To: #{to}"
f.puts "Subject: #{subject}"
f.puts
f.puts "#{message}"
end
end
end
end

=begin
#test code for the class commented out when trying to use within project
a = Sendemail.new

a.send_email "isp.email.address", "(e-mail address removed)", "test", "a
message", "smtp.isp.mail.server"

=end

I have changed the calling code (shown again below)
@email.send_email(@sender,receipiant, 'Automatic Patrol Report', @msg,
@server)

to code below thinking the code below will fix things to no avail.
@email.send_email("#{@sender}","#{receipiant}", "Automatic Patrol
Report", "#{@msg}", "#{@server}")

Why? I am sending across 5 parameters, see the test case above it works!
it I for go 1 parameter then it works, but which one do I loose and why
that one?

I want the class to be as dynamic as possible so I can "just" call it
into another project I want to send emails out from.

any help appreciated.

dave
 
D

Dave Lilley

thanks MRZombie,

Will look into this.

still have you any ideas why I have my current problem thou?
 
D

Dave Lilley

update to the issue.

Have tried code sample posted at this url
http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2009-06/msg02082.html

and still get my error!!!

now can anyone explain to me why this issue is happening?

I have my fox class app.

my email class being required into it.
a module being required into it also.

in the init of my fox class i have....

@email = @Emails.new

but when ever I edit the script it seems not to reflect in my execution
(eg i've commented out *ALL* references to require net/smtp, Net::SMTP
code but i still get an error relating to 5 parameters passed when only
4 are required.

this is strange (unless is the GC not clearing out the last run of my
program).
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top