Email/SMTP::NET Problems

Greetings,

This is my first time posting but this problem I am having is really
annoying.

Here is a section of my code:

fname = cgi['fname']
lname = cgi['lname']
pw = cgi['password']
em = cgi['email']
buf = "<body bgcolor=gray><br>"

myMessage = <<END_OF_MESSAGE

···

From: Highpoint Alumni <hpualumni@highpoint.edu>
To: #{fname} #{lname} <#{em}>
Subject: HPU Alumni Verification

Thank you for registering with Highpoint Alumni. Please click the
following link in order to activate your account.

Your password is: #{pw}
END_OF_MESSAGE

    Net::SMTP.start('linus.xxxxxx.edu') do |smtp|
               smtp.send_message myMessage,
            'hpualumni@xxxx.edu', em
      end

end

I've x'd out some of the information. But the problem I am having I
think is that it will not allow me to use "em" as an email address to
send. I can physically change em to 'whateveriwant@whatever.com' and it
will work perfectly fine. I'm taking this email address out of a
POST-REQUEST form so I need the flexibility to store it as a variable
and send whatever that variable the email is. Any suggestions would be
awesome, and if you need more information please let me know.

Brantley
--
Posted via http://www.ruby-forum.com/.

Anyone have any idea of a quick solution?

I've tried using:

Net::SMTP.start('linus.xxxxxx.edu') do |smtp|
     smtp.send_message myMessage,
    'hpualumni@xxxx.edu', '#{em}'
end

and lots other options. I just need to know how I can store the email
address so that I can send the string or whatever. Thanks.

Brantley

···

--
Posted via http://www.ruby-forum.com/.

ok i had another look at this example, which doesn't look bad at
all. for i'm not able to find an error i've to ask: are you sure that
cgi['email'] actually holds the emailaddress desired? Does the
emailaddress appear in the generated content of the message?

g phil

···

On Thu, Apr 24, 2008 at 11:28:16AM +0900, Brantley Shields wrote:

Greetings,

This is my first time posting but this problem I am having is really
annoying.

Here is a section of my code:

fname = cgi['fname']
lname = cgi['lname']
pw = cgi['password']
em = cgi['email']
buf = "<body bgcolor=gray><br>"

myMessage = <<END_OF_MESSAGE
From: Highpoint Alumni <hpualumni@highpoint.edu>
To: #{fname} #{lname} <#{em}>
Subject: HPU Alumni Verification

Thank you for registering with Highpoint Alumni. Please click the
following link in order to activate your account.

Your password is: #{pw}
END_OF_MESSAGE

    Net::SMTP.start('linus.xxxxxx.edu') do |smtp|
               smtp.send_message myMessage,
            'hpualumni@xxxx.edu', em
      end

end

I've x'd out some of the information. But the problem I am having I
think is that it will not allow me to use "em" as an email address to
send. I can physically change em to 'whateveriwant@whatever.com' and it
will work perfectly fine. I'm taking this email address out of a
POST-REQUEST form so I need the flexibility to store it as a variable
and send whatever that variable the email is. Any suggestions would be
awesome, and if you need more information please let me know.

Brantley

It might be that I'm missing something but

'#{em}'

just looks wrong. Try

"#{em}"

so it gets evaled.

but of course

"#{em}"

is equiv to

em

g phil

···

On Thu, Apr 24, 2008 at 11:50:52AM +0900, Brantley Shields wrote:

Anyone have any idea of a quick solution?

I've tried using:

Net::SMTP.start('linus.xxxxxx.edu') do |smtp|
     smtp.send_message myMessage,
    'hpualumni@xxxx.edu', '#{em}'
end

and lots other options. I just need to know how I can store the email
address so that I can send the string or whatever. Thanks.

Brantley

Yes it does hold the email, I comment out the attempt on sending the
email, and just print out the em like this:

buf+="em is: #{em}<br>"

which produces:

myemail@yahoo.com

on the screen. So....I think that does answer your question

Brantley

···

--
Posted via http://www.ruby-forum.com/.

you need

Net::SMTP.start('linus.xxxxxx.edu') do |smtp|
   smtp.send_message myMessage, 'hpualumni@xxxx.edu', em
end

is all i think.

a @ http://codeforpeople.com/

···

On Apr 23, 2008, at 8:50 PM, Brantley Shields wrote:

Net::SMTP.start('linus.xxxxxx.edu') do |smtp|
    smtp.send_message myMessage,
   'hpualumni@xxxx.edu', '#{em}'
end

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

Phil,

Thanks for replying. I attempted that method as well and it does not
work either, as you said it is equiv to em. I've been constantly
browsing the net to find a solution, but nothing is coming up. Any other
ideas that pop up let me know. Thanks in advance.

Brantley

···

--
Posted via http://www.ruby-forum.com/.

This simple problem has caused me more grief than I think its worth
honestly :frowning:

Brantley

···

--
Posted via http://www.ruby-forum.com/.

Yes it does hold the email, I comment out the attempt on sending the email, and just print out the em like this:

buf+="em is: #{em}<br>"

which produces:

myemail@yahoo.com

on the screen. So....I think that does answer your question

What if you print the whole myMessage to the buffer?

For ex:

buf << "<pre>#{CGI.escapeHTML(myMessage)}</pre>"

...so that we can see exactly what is being substituted for 'em' in the email?

Regards,

Bill

···

From: "Brantley Shields" <brantley_shields@yahoo.com>

I thought the same,

I knew em was holding the email address just fine, but you can't stick
em on the end and it just send the email, I can't put anything other
than 'an_emailAddres@something.com' otherwise I get an error....Not sure
how to get around this is my point...

Brantley

···

--
Posted via http://www.ruby-forum.com/.

Bill,

Thank you for your response. I put myMessage into the buffer and it
printed out the entire message as follows:

Verification Thank you for registering with us. Please click the
following link to activate your account.
http://xxxx.higxxxxnt.edu/~xxxxs/alumni/verify.rbx Your password is:
xxxx

Now as you can see, the #{em} did not print out the the To: statement,
but I'm not sure that it should in this instance. So I made another line
that says this:

buf += "Email is: #{em}<br>" results:
blahblah_blathblah@yahoo.com

So it seems as if em is getting the email address, but I'm still
completely lost as to why I cannot use this string to send the
emailaddress. I've changed the email to something@yahoo.com to make sure
the underscore was not causing any problems but same problem occurs.
Thanks for your time!

Brantley

···

From: Highpoint Alumni To: brantley shields Subject: HPU Alumni
--
Posted via http://www.ruby-forum.com/.

just realized - you have the arguments reversed

it's

   msg, to, from

not

   msg, from, to

which is what you have i think

a @ http://codeforpeople.com/

···

On Apr 23, 2008, at 11:56 PM, Brantley Shields wrote:

I thought the same,

I knew em was holding the email address just fine, but you can't stick
em on the end and it just send the email, I can't put anything other
than 'an_emailAddres@something.com' otherwise I get an error....Not sure
how to get around this is my point...

Brantley

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

On Behalf Of Brantley Shields
# I knew em was holding the email address just fine, but you
# can't stick
# em on the end and it just send the email, I can't put anything other
# than 'an_emailAddres@something.com' otherwise I get an
# error....Not sure
# how to get around this is my point...

you seem to be doing web thingy, so

1 pls replace em with another variable email or address will do. we try to avoid template clobbering..

2 when posting problems pls show logs fr client and fr server

3 put debugging options on your code, eg using net/smtp, i usually do,

   smtp.set_debug_output $stderr # verbose output mail session

kind regards -botp

this can't be correct. your code has '<' and '>' around the addr but those are not there - did you use CGI.escapeHTML??

another thought - do not use to_s to check out your email addr - use

"em: #{ CGI.escapeHTML em.inspect } <br />"

i think you've got something like a stray newline or html char horking things up.

a @ http://codeforpeople.com/

···

On Apr 23, 2008, at 11:18 PM, Brantley Shields wrote:

From: Highpoint Alumni To: brantley shields Subject: HPU Alumni
Verification Thank you for registering with us. Please click the
following link to activate your account.
http://xxxx.higxxxxnt.edu/~xxxxs/alumni/verify.rbx Your password is:
xxxx

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

It is:

  Net::SMTP.start('mail.my.com') do |smtp|
    smtp.send_message myMessage, 'postmaster@my.com', send_to
  end

My question is. Are you sure that em = cgi['email'] is a String object?
Try to use em.to_s.

by
TheR

···

--
Posted via http://www.ruby-forum.com/.

No, i think he has them the right way around. I can't see anything wrong
with what Brantley is doing though. I've included some code that I use that
does pretty much the same thing, and I know it works. The only real
difference, is I haven't used <<HEREDOC syntax. But it does the same thing.
Hopefully this will help.

The email is going from the student, to the trainer.

def submit_results(sid, cid, aid, results)
    student = ::Student[sid]
    result = student.submit_results(cid, aid, results)
    trainer = student.get_trainer(cid)
    course = ::Course[cid]
    assessment = ::Assessment[aid]
    submissionEmail = "From: #{student.first_name} #{student.last_name}
<#{student.email}>\n"
    submissionEmail += "To: #{trainer.first_name} #{trainer.last_name}
<#{trainer.email}>\n"
    submissionEmail += "Subject: Assessment Submission: '#{course.name}' -
'#{assessment.name}'\n\n"
    submissionEmail += "#{student.first_name} has submitted results for '#{
assessment.name}' in '#{course.name}'.\n"
    submissionEmail += "Please log in to mark #{student.first_name}'s
answers.\n\n"
    Net::SMTP.start('localhost') {|smtp| smtp.send_message(submissionEmail,
student.email, trainer.email)}
    result
  end

···

On Thu, Apr 24, 2008 at 3:58 PM, ara.t.howard <ara.t.howard@gmail.com> wrote:

On Apr 23, 2008, at 11:56 PM, Brantley Shields wrote:

> I thought the same,
>
> I knew em was holding the email address just fine, but you can't stick
> em on the end and it just send the email, I can't put anything other
> than 'an_emailAddres@something.com' otherwise I get an error....Not sure
> how to get around this is my point...
>
>
> Brantley
>

just realized - you have the arguments reversed

it's

msg, to, from

not

msg, from, to

which is what you have i think

a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama

--

"Every child has many wishes. Some include a wallet, two chicks and a cigar,
but that's another story."

Greetings,

I've found some information that may be useful to those helping me on
this small project. The following code works just fine:

from_address = 'bshields@linus.highpoint.edu'
to_address = 'brantley_shields@yahoo.com'
    Net::SMTP.start('linus.highpoint.edu') do |smtp|
         smtp.send_message(myMessage,from_address,to_address)
         end

So, what is the difference between " and ' to ruby? I checked the error
logs on my server (got ahold of the administrator) and the logs show a
tainted to_address. I know the email itself is not tainted and that it
will send an email address to the one being put into to_address. I've
tried multiple simple email addresses such as "hello@yahoo.com" which
would not be tainted. So I think its confusing the string or whatever
to_address is being referred to as, its interpretting it as something
else. how can I convert to_address to 'somelikethis' ?

Brantley

···

--
Posted via http://www.ruby-forum.com/.

buf+="em: #{ CGI.escapeHTML em.inspect } <br />"
returns:
em: "brantley_shields@yahoo.com"

I'm not sure where your going with this, I'm sure you can tell I'm new
to Ruby. Thanks for having a look, let me know what you think

Brantley

···

--
Posted via http://www.ruby-forum.com/.

show us the error. to untaint you can do something like

em = "#{ em }"

a @ http://codeforpeople.com/

···

On Apr 24, 2008, at 8:18 AM, Brantley Shields wrote:

So, what is the difference between " and ' to ruby? I checked the error
logs on my server (got ahold of the administrator) and the logs show a
tainted to_address. I know the email itself is not tainted and that it
will send an email address to the one being put into to_address. I've
tried multiple simple email addresses such as "hello@yahoo.com" which
would not be tainted. So I think its confusing the string or whatever
to_address is being referred to as, its interpretting it as something
else. how can I convert to_address to 'somelikethis' ?

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

Brantley Shields wrote:

buf+="em: #{ CGI.escapeHTML em.inspect } <br />"
returns:
em: "brantley_shields@yahoo.com"

I'm not sure where your going with this, I'm sure you can tell I'm new
to Ruby. Thanks for having a look, let me know what you think

Brantley

buf+="myMessage: #{ CGI.escapeHTML myMessage.inspect } <br />"

returns:

myMessage: "From: Highpoint Alumni <hpualumni@highpoint.edu>\nTo:
brantley shields <brantley_shields@yahoo.com>\nSubject: HPU Alumni
Verification\n\nThank you for registering with us. Please click the
following link to activate your
account.\nhttp://linus.highpoint.edu/~bshields/alumni/verify.rbx\nYour
password is: cagenu\n"

Sorry for double post, I think this is useful

Brantley

···

--
Posted via http://www.ruby-forum.com/\.