Hello,
I am new to this forum so please go easy. I am just trying to figure out for the first time how to send an email with an attachement using perl and a form so that users of my site can send a resume.
I keep getting 500 Errors without any detail. the hosting I use says to follow these instructions below to make sure i can use the modules.
I have made sure MIME::lite is there:
Location of Your Perl Module(s)
Path: /home/lot49495/perl
Using Your Perl Module(s)
You will need to add /home/lot49495/perl to the include path.
You can do this by adding the following code to your script:
BEGIN {
my $homedir = ( getpwuid($>) )[7];
my @user_include;
foreach my $path (@INC) {
if ( -d $homedir . '/perl' . $path ) {
push @user_include, $homedir . '/perl' . $path;
}
}
unshift @INC, @user_include;
}
Any help would be greatly appreciated.
Here is the whole thing:
_____________________________________________
#!/usr/bin/perl -w
BEGIN {
my $homedir = ( getpwuid($>) )[7];
my @user_include;
foreach my $path (@INC) {
if ( -d $homedir . '/perl' . $path ) {
push @user_include, $homedir . '/perl' . $path;
}
}
unshift @INC, @user_include;
}
# use MIME::Lite package
use MIME::Lite;
#Parse the Form Data
&GetData(*in);
# set up email
$smtp = "mail.mydomain.com.au";
$to = "michael\@mydomain.com.au";
$from = "michael\@yourdomain.com";
$subject = "Email Sent via Perl";
$message = "This email was sent using Perl.";
$file = "sample.txt";
# send email
#&email($to, $from, $subject, $message, $file);
# email function
sub email
{
#get incoming parameters
local ($to, $from, $subject, $message, $file) = @_;
# create a new message
$msg = MIME::Lite->new(
From => $from,
To => $to,
Subject => $subject,
Data => $message
);
# add the attachment
$msg->attach(
Type => "text/plain",
Path => $file,
Filename => $file,
Disposition => "attachment"
);
# send the email
MIME::Lite->send('smtp', $smtp, Timeout => 60);
$msg->send();
}
print "Content-type: text/html\n\n";
print "<div align=\"center\"><b>Thankyou for your request <br>We will get back to you ASAP.</b></div>";
_________________________________________________
Thanks again.
I am new to this forum so please go easy. I am just trying to figure out for the first time how to send an email with an attachement using perl and a form so that users of my site can send a resume.
I keep getting 500 Errors without any detail. the hosting I use says to follow these instructions below to make sure i can use the modules.
I have made sure MIME::lite is there:
Location of Your Perl Module(s)
Path: /home/lot49495/perl
Using Your Perl Module(s)
You will need to add /home/lot49495/perl to the include path.
You can do this by adding the following code to your script:
BEGIN {
my $homedir = ( getpwuid($>) )[7];
my @user_include;
foreach my $path (@INC) {
if ( -d $homedir . '/perl' . $path ) {
push @user_include, $homedir . '/perl' . $path;
}
}
unshift @INC, @user_include;
}
Any help would be greatly appreciated.
Here is the whole thing:
_____________________________________________
#!/usr/bin/perl -w
BEGIN {
my $homedir = ( getpwuid($>) )[7];
my @user_include;
foreach my $path (@INC) {
if ( -d $homedir . '/perl' . $path ) {
push @user_include, $homedir . '/perl' . $path;
}
}
unshift @INC, @user_include;
}
# use MIME::Lite package
use MIME::Lite;
#Parse the Form Data
&GetData(*in);
# set up email
$smtp = "mail.mydomain.com.au";
$to = "michael\@mydomain.com.au";
$from = "michael\@yourdomain.com";
$subject = "Email Sent via Perl";
$message = "This email was sent using Perl.";
$file = "sample.txt";
# send email
#&email($to, $from, $subject, $message, $file);
# email function
sub email
{
#get incoming parameters
local ($to, $from, $subject, $message, $file) = @_;
# create a new message
$msg = MIME::Lite->new(
From => $from,
To => $to,
Subject => $subject,
Data => $message
);
# add the attachment
$msg->attach(
Type => "text/plain",
Path => $file,
Filename => $file,
Disposition => "attachment"
);
# send the email
MIME::Lite->send('smtp', $smtp, Timeout => 60);
$msg->send();
}
print "Content-type: text/html\n\n";
print "<div align=\"center\"><b>Thankyou for your request <br>We will get back to you ASAP.</b></div>";
_________________________________________________
Thanks again.