SMTP SMS Reminder Script

require ‘net/smtp’
puts “How many times do you want to bomb 'em?”
x = gets.to_i
puts “What’s your gmail account?”
username = gets
puts “Password for that account?”
password=gets
message = <<MESSAGE_END
From: Private P.
To: A Test User
Subject: Test
This is a test e-mail message.
MESSAGE_END
Times_Sent = gets.to_i
Net::SMTP.start(‘smtp.gmail.com’, 587, ‘gmail.com’,
username, password, :plain) do |smtp|
smtp.send_message message
@gmail.com
@txt.att.net
end
while Times_Sent < x
Times_Sent = Times_Sent + 1
end
puts “#{Times_Sent} sent successfully!”

This isn’t wokring for some reason, it’s supposed to send sms messages
to remind people of stuff, you can send them many times, but the
authentacation doesn’t work. Help?

Hd Pwnz0r wrote:

username = gets

password=gets

Probably it’s the newline on the end of the username and password. Try

username = gets.chomp
password = gets.chomp

Brian C. wrote:

Hd Pwnz0r wrote:

username = gets

password=gets

Probably it’s the newline on the end of the username and password. Try

username = gets.chomp
password = gets.chomp

I’ve tried that previously, the script just sits there until I interrupt
it.

Hd Pwnz0r wrote:

Brian C. wrote:

Hd Pwnz0r wrote:

username = gets

password=gets

Probably it’s the newline on the end of the username and password. Try

username = gets.chomp
password = gets.chomp

I’ve tried that previously, the script just sits there until I interrupt
it.

Sure. So you have another bug. To be sure, try typing a wrong password
and see if it’s rejected.

Try adding some STDERR.puts “…” lines to see how far you’re getting.

I note some strange things in your script:

Net::SMTP.start(‘smtp.gmail.com’, 587, ‘gmail.com’,
username, password, :plain) do |smtp|
smtp.send_message message
@gmail.com’ #<< this line does nothing
@txt.att.net’ #<< this line does nothing
end

and:

while Times_Sent < x
Times_Sent = Times_Sent + 1 # This just loops until Times_sent == x
end

I suggest you start with the simplest possible script - which sends one
E-mail - before making it more complex. Google for “ruby Net::SMTP
gmail” to find some working examples.

require ‘net/smtp’
require ‘smtp-tls’
require ‘rubygems’
puts “How many times do you want to bomb 'em?”
x = gets.to_i
puts “What’s your gmail account? (Without @gmail.com)”
username = gets.chomp
from = username
puts “Password for that account?”
password=gets.chomp
puts “What’s the number you want to bomb?”
victim = gets.chomp
to = victim
puts “What do you want the message bombed to be?”
body = gets.chomp
message = <<MESSAGE_END
From: you #{username}@gmail.com
To: Victim #{victim}@txt.att.net
#{body}
MESSAGE_END
smtp = Net::SMTP.new ‘smtp.gmail.com’, 587
smtp.enable_starttls
smtp.start(Socket.gethostname,username,password,:login) do |server|
server.send_message message, #{from}@gmail.com, #{to}@txt.att.net
end
while Times_Sent < x
Times_Sent = Times_Sent + 1
end
puts “#{Times_Sent} sent successfully!”

Here’s the updated version. Weird error, I’ve never seen it before.

Error:

sms.rb:24:in block in <main>': wrong number of arguments (1 for 2) (ArgumentError) from C:/Ruby191/lib/ruby/1.9.1/net/smtp.rb:526:in start’
from sms.rb:23:in `’

Brian C. wrote:

Hd Pwnz0r wrote:

Brian C. wrote:

Hd Pwnz0r wrote:

username = gets

password=gets

Probably it’s the newline on the end of the username and password. Try

username = gets.chomp
password = gets.chomp

I’ve tried that previously, the script just sits there until I interrupt
it.

Sure. So you have another bug. To be sure, try typing a wrong password
and see if it’s rejected.

Try adding some STDERR.puts “…” lines to see how far you’re getting.

I note some strange things in your script:

Net::SMTP.start(‘smtp.gmail.com’, 587, ‘gmail.com’,
username, password, :plain) do |smtp|
smtp.send_message message
@gmail.com’ #<< this line does nothing
@txt.att.net’ #<< this line does nothing
end

and:

while Times_Sent < x
Times_Sent = Times_Sent + 1 # This just loops until Times_sent == x
end

I suggest you start with the simplest possible script - which sends one
E-mail - before making it more complex. Google for “ruby Net::SMTP
gmail” to find some working examples.

stderr:

/usr/lib/ruby/1.8/net/smtp.rb:551:in initialize': getaddrinfo: Servname not supported for ai_socktype (SocketError) from /usr/lib/ruby/1.8/net/smtp.rb:551:in open’
from /usr/lib/ruby/1.8/net/smtp.rb:551:in do_start' from /usr/lib/ruby/1.8/timeout.rb:62:in timeout’
from /usr/lib/ruby/1.8/timeout.rb:93:in timeout' from /usr/lib/ruby/1.8/net/smtp.rb:551:in do_start’
from /usr/lib/ruby/1.8/net/smtp.rb:525:in start' from /usr/lib/ruby/1.8/net/smtp.rb:463:in start’
from prog.rb:15

There’s the stderr, and I’ll check into that thanks. It still gets the
output but there’s a socketerror.