View Full Version : Please help, PERL people! (how to generate an email?)
cozbaldwin
02-14-2005, 07:36 AM
Alright so I use a cgi based commenting system on my blog. The form is in perfect working condition and does all that it should do. What I WANT is an email notification (and/or contents of the form) emailed to me upon submission. This appears impossible with HTML because it's form action tag is already being used and only one action can be done per button. This is how the tag looks now: < form action="$WebPath{'commentscript'}?id=$Query{'id'}&item=$Query{'item'}&action=post" method="post" >
my blog: http://www.cozbaldwin.com -- so you can see what I'm talking about.
I'm thinking (since I know nothing about PERL) that maybe there's a file in the 'Bin that will give me the option to add a tag to generate an email upon submission of the form. Can anyone please help me??? It would be greatly appreciated. I can supply you with contents of the other files if you need to see some more script from somewhere else. Thanks!
mlseim
02-14-2005, 02:09 PM
If the Perl script is installed in YOUR cgi-bin, you can add a part
to do the email right inside the script. If your Blogger is remotely
hosted by someone else, you won't be able to alter the script.
cozbaldwin
02-14-2005, 03:09 PM
If the Perl script is installed in YOUR cgi-bin, you can add a part
to do the email right inside the script. If your Blogger is remotely
hosted by someone else, you won't be able to alter the script.
Yes, I host it. I just need to know the command to add to the script. I can't figure out where to put it and what that command would be.
mlseim
02-14-2005, 04:29 PM
You need to define the variables for yourself, and paste the code
somewhere in your script like right before it writes the information
to a file. Since we can't see your script, we're not sure.
You'll have to figure out what variable to insert that contains
the blogger text, or whatever email message you want sent.
You'll have to try the "sendmail" path provided, but it may be
different with your webhost.
You can add more print commands within the mail portion. Keep
your lines looking the same, with the same punctuation marks.
\n = new line (linefeed)
#--- cut and paste the lines below ---
################################################
# Send the E-mail
#
#This is the most common path to the "sendmail" program:
$mailprogram = "/usr/sbin/sendmail";
$myemail = "joe\@aol.com"; #Your email address here with "\" in front of @
$email = "joe\@aol.com"; #Who the email is from. (probably yourself?)
$message = $blogger_text; #Whatever the text is from the blogger message.
open (MAIL, "|$mailprogram -t") or die "Can't fork sendmail.\n";
print MAIL "To: $myemail\n";
print MAIL "From: $email\n";
print MAIL "Subject: Email From my Blogger\n";
print MAIL "\n\n";
print MAIL "Description: $message\n\n";
print MAIL "=====================================================\n";
close(MAIL);
##################################################
cozbaldwin
02-14-2005, 09:08 PM
this is extremely helpful and I'm trying to play with it to do the right thing --- so far, there is an email generated upon opening of the form, and i think another one sends upon posting of the form conents... however i cant figure out what command is the actual contents the people fill out into the form. ive tried it all. also, i obviously only want an email once the form is completed so i think im putting the code in the wrong place (the very top) but when i put in within the html tags, they are displayed as content.
The current template of the form with the code you supplied is here: http://cozbaldwin.com/Cozisms.txt
Do you think you can help me to know a better place to put the code and how to get the message of the email to contain all the fields they filled out as well as the post id#. ??
Again, this has been most helpful and appreciated.
mlseim
02-14-2005, 11:51 PM
I'm thinking you might have the email thing in the wrong script.
The script you provided displays the form and another one processes it?
How many scripts are involved?
Maybe if you give us a link to your actual online form, I can see
where the form is directing the values.
As for where it is now ...
It for sure doesn't go at the top.
cozbaldwin
02-15-2005, 02:08 AM
for anyone else who comes across this post, it has been resolved with tremendous help from "mlseim" -- I thank that user and look forward to utilizing this board the next time I come across an issue.
Digger3000
02-19-2005, 08:31 AM
I'm trying to do this too. I copied that code and changed it to fit my form but it doesn't send me an e-mail. Do I need to get any modules or something?
mlseim
02-19-2005, 06:14 PM
Digger,
It's possible that the "sendmail" program is located in
a different spot on your webhost's server:
#This is the most common path to the "sendmail" program:
$mailprogram = "/usr/sbin/sendmail";
You may have to ask them what that path is ...
But, post a link to your HTML form, and then post your
Perl script on here so we can see what you're doing.
Digger3000
02-20-2005, 01:22 AM
I got a new apache server so my server is on my computer. Does that mean I have to get a sendmail program?
mlseim
02-20-2005, 02:48 AM
I don't know much about servers. Maybe you can look at a different
forum about "sendmail". I would assume it's part of Apache.
Digger3000
02-23-2005, 02:35 AM
Ok so how do I do this? Where do I get sendmail (is it sendmail.pm?) and where do I put it?
Digger3000
02-25-2005, 03:28 AM
Does anyone know anything about an SMTP server?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.