CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Mailing-problem

 



husbil
Deleted

Apr 7, 2001, 8:06 AM

Post #1 of 2 (160 views)
Mailing-problem Can't Post

Problems for a beginner!
I have a html page that contain a button and a text field. When I
press the button I want an email to be sent
to the emailaddress that I have written in the textfield. But something is
wrong with code, because the code does not send any email. Perhaps there is an
outgoing email but it does't go to the "typed" address.
The code looks like this:

#!/usr/local/bin/perl

# path to the mailprogram
$mail_prog = "/usr/sbin/sendmail";

# get size of post data
$size_of_data = $ENV{'CONTENT_LENGTH'};

# get post data
read (STDIN, $post_data, $size_of_data);

# convert escape characters
$post_data =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C",hex($1))/eg;
$post_data =~ tr/\+/ /;

# $post_data now "points" at for instance info=nilsson@mail.bip.net.
# For some reason I have to insert a "\" before the "@" sign. And
# of course I have to remove the "info=" to get the posted emailaddress.
@a = split(/@/, $post_data);
$b = "\\@";
$c = "@a[0]$b@a[1]";
@d = split(/=/, $c);

# Who is the e-mail going too?
$mailto = "@d[1]";

# Who is it from?
$from = "Test";

# What is the subject?
$subject = "Testing";


# START TO SEND THE E-MAIL OUT
open (MAIL, "|$mail_prog -t");
print MAIL "To: $mailto\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject \n\n";
print MAIL "Testing\n ";
close(MAIL);

print "Content-type: text/html\n\n";
print "OK\n";

exit;





unknownSym
stranger

Apr 7, 2001, 3:07 PM

Post #2 of 2 (152 views)
Re: Mailing-problem [In reply to] Can't Post

$c = "@a[0]$b@a[1]";

Change the above line to:

$c = join($b, @a);

That should in theory help you solve your problem. However your main problem is that your '@' signs should be '$', because the elements of @a are not pointing to an array, therefore you need to use a '$' to get at the value of each element in @a.

Happy coding.

--unknownSym


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives