PDA

View Full Version : perl question


jonsaul
09-05-2006, 09:19 AM
I have a perl script using jmail, its just collecting a simple form's contents.
The problem I have is that when the content of the form is emailed back to me it isn't really very neat.

I know no perl what so ever, could anyone offer any advice on formatting the text the form returns via the perl script ??

Even just very simple stuff like how to place a line break after a value is returned would help.

davidj
10-13-2006, 08:23 AM
sorry jonsaul

this one got away from me

try \n or \r

if your email is returning to an html configured client you could use HTML tags as normal with in your script. Just concatinate them after you collect the var contents

if you still need help then post your script and ill work it out

davidj
10-13-2006, 01:47 PM
try this...

notice the print "\n"; at the output (bottom of script)

use OLE;
use CGI;
$jmail = CreateObject OLE "JMail.SMTPMail";

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

$form = new CGI;
$domain = $ENV {'SERVER_NAME'};
$referer = $ENV {'HTTP_REFERER'};
$url = $referer;
$url =~ s/^http:\/\///i;
$url =~ s/^www\.//i;
$domain =~ s/^www\.//i;
$Recipient="tech\@$domain";
$Sender = $form->param('email');


$SMTPServer = "smtp.$domain:25";
$Subject = "Ezines Contact form";
$Body = "Name: ".$form->param('name'). "Subject: ".$form->param('subject'). "Message : ".$form->param('message');


$Priority=3;
$Header = "Originating-IP", $ENV{'REMOTE_ADDR'};

$jmail->{ServerAddress} = $SMTPServer;
$jmail->{Sender} = $Sender;
$jmail->{Subject} = $Subject;
$jmail->AddRecipient ($Recipient);
$jmail->{Body} = $Body;
$jmail->{Priority} = $Priority;
$jmail->AddHeader ($Header);

if ($url =~ m/^$domain/) {
$mailmessage = "Thankyou. Your e-mail has been received.";
$jmail->Execute;
} else {
$mailmessage = "Sorry, there has been an error, please try again.";
}

print "Result: $mailmessage Recipient: $Recipient";
print "\n";
print "Sender: $Sender SMTP Server: $SMTPServer";
print "\n";
print "Subject: $Subject/n/r Referer: $referer";
print "\n";
print "Domain: $domain url: $url ";