Email/SMTP::NET Problems

B

Brantley Shields

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 <[email protected]>
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,
'(e-mail address removed)', 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 '(e-mail address removed)' 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
 
B

Brantley Shields

Anyone have any idea of a quick solution?

I've tried using:

Net::SMTP.start('linus.xxxxxx.edu') do |smtp|
smtp.send_message myMessage,
'(e-mail address removed)', '#{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
 
P

Philipp Hofmann

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
 
B

Brantley Shields

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
 
P

Philipp Hofmann

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
 
B

Brantley Shields

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:

(e-mail address removed)

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

Brantley
 
B

Brantley Shields

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

Brantley
 
B

Bill Kelly

From: "Brantley Shields said:
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:

(e-mail address removed)

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
 
B

Brantley Shields

Bill,

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

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

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:
(e-mail address removed)


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 (e-mail address removed) to make sure
the underscore was not causing any problems but same problem occurs.
Thanks for your time!

Brantley
 
A

ara.t.howard

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

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/
 
B

Brantley Shields

buf+="em: #{ CGI.escapeHTML em.inspect } <br />"
returns:
em: "(e-mail address removed)"

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
 
B

Brantley Shields

Brantley said:
buf+="em: #{ CGI.escapeHTML em.inspect } <br />"
returns:
em: "(e-mail address removed)"

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 <[email protected]>\nTo:
brantley shields <[email protected]>\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
 
A

ara.t.howard

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

returns:

myMessage: "From: Highpoint Alumni <[email protected]>\nTo:
brantley shields <[email protected]>\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

so there you go - the address is right there. what's the issue now?

a @ http://codeforpeople.com/
 
A

ara.t.howard

Net::SMTP.start('linus.xxxxxx.edu') do |smtp|
smtp.send_message myMessage,
'(e-mail address removed)', '#{em}'
end


you need

Net::SMTP.start('linus.xxxxxx.edu') do |smtp|
smtp.send_message myMessage, '(e-mail address removed)', em
end

is all i think.


a @ http://codeforpeople.com/
 
B

Brantley Shields

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 '(e-mail address removed)' otherwise I get an error....Not sure
how to get around this is my point...


Brantley
 
A

ara.t.howard

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 '(e-mail address removed)' 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/
 
D

Damjan Rems

It is:

Net::SMTP.start('mail.my.com') do |smtp|
smtp.send_message myMessage, '(e-mail address removed)', 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
 
P

Peña, Botp

T24gQmVoYWxmIE9mIEJyYW50bGV5IFNoaWVsZHMNCiMgSSBrbmV3IGVtIHdhcyBob2xkaW5nIHRo
ZSBlbWFpbCBhZGRyZXNzIGp1c3QgZmluZSwgYnV0IHlvdSANCiMgY2FuJ3Qgc3RpY2sgDQojIGVt
IG9uIHRoZSBlbmQgYW5kIGl0IGp1c3Qgc2VuZCB0aGUgZW1haWwsIEkgY2FuJ3QgcHV0IGFueXRo
aW5nIG90aGVyIA0KIyB0aGFuICdhbl9lbWFpbEFkZHJlc0Bzb21ldGhpbmcuY29tJyBvdGhlcndp
c2UgSSBnZXQgYW4gDQojIGVycm9yLi4uLk5vdCBzdXJlIA0KIyBob3cgdG8gZ2V0IGFyb3VuZCB0
aGlzIGlzIG15IHBvaW50Li4uDQoNCnlvdSBzZWVtIHRvIGJlIGRvaW5nIHdlYiB0aGluZ3ksIHNv
DQoNCjEgcGxzIHJlcGxhY2UgZW0gd2l0aCBhbm90aGVyIHZhcmlhYmxlIGVtYWlsIG9yIGFkZHJl
c3Mgd2lsbCBkby4gd2UgdHJ5IHRvIGF2b2lkIHRlbXBsYXRlIGNsb2JiZXJpbmcuLg0KDQoyIHdo
ZW4gcG9zdGluZyBwcm9ibGVtcyBwbHMgc2hvdyBsb2dzIGZyIGNsaWVudCBhbmQgZnIgc2VydmVy
DQoNCjMgcHV0IGRlYnVnZ2luZyBvcHRpb25zIG9uIHlvdXIgY29kZSwgZWcgdXNpbmcgbmV0L3Nt
dHAsIGkgdXN1YWxseSBkbywNCg0KICAgc210cC5zZXRfZGVidWdfb3V0cHV0ICRzdGRlcnIgICAj
IHZlcmJvc2Ugb3V0cHV0IG1haWwgc2Vzc2lvbg0KDQpraW5kIHJlZ2FyZHMgLWJvdHANCg==
 
B

Brantley Shields

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 = '(e-mail address removed)'
to_address = '(e-mail address removed)'
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 "(e-mail address removed)" 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
 
A

ara.t.howard

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 "(e-mail address removed)" 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' ?

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


em = "#{ em }"



a @ http://codeforpeople.com/
 

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

net/smtp Multiple Email recipients Issue 2
Simple SMTP server in ruby 2
net/smtp 6
SMTP SMS Reminder Script 5
Mail Using SMTP Problem 2
net/smtp question 6
Problems sending mail 0
Net/SMTP Question 0

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top