[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Email/SMTP::NET Problems

Brantley Shields

4/24/2008 2:28:00 AM

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-....

25 Answers

Brantley Shields

4/24/2008 2:51:00 AM

0

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-....

Philipp Hofmann

4/24/2008 2:57:00 AM

0


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

Brantley Shields

4/24/2008 3:04:00 AM

0

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-....

Philipp Hofmann

4/24/2008 3:33:00 AM

0


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

Brantley Shields

4/24/2008 3:51:00 AM

0

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-....

Brantley Shields

4/24/2008 4:25:00 AM

0

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

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

Bill Kelly

4/24/2008 4:46:00 AM

0


From: "Brantley Shields" <brantley_shields@yahoo.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



Brantley Shields

4/24/2008 5:19:00 AM

0

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/... 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
--
Posted via http://www.ruby-....

ara.t.howard

4/24/2008 5:28:00 AM

0


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/... 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://codeforp...
--
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

4/24/2008 5:36:00 AM

0


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-....