Solved

script isn't sending email to me

Posted on 2002-04-27
5
173 Views
Last Modified: 2010-03-05
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";


use CGI qw(:standard);

open(MAIL, "|/usr/sbin/sendmail -oi -t") or die "can't do sendmail: $!";
print MAIL <<eof;
From: mysite.com
To: me@ix.netcom.com
Subject: Someone submitted information via your form

[form info here]

eof
save_parameters(*MAIL);
close(MAIL) or die "can't close sendmail: $!";

print <<VERIFY;

Email sent.

VERIFY

*********************

I'm seeing "Email sent" in the browser, but I'm receiving no email.  No error messages.  I think I should see

From: mysite.com
To: me@ix.netcom.com
Subject: Someone submitted information via your form

[form info here]

0
Comment
Question by:miredo
5 Comments
 
LVL 12

Expert Comment

by:lexxwern
ID: 6973284
Does your server have Sendmail??
0
 

Author Comment

by:miredo
ID: 6974439
Yes, on my account page, my host posts the path to sendmail:
/usr/sbin/sendmail
0
 
LVL 1

Expert Comment

by:andy_wolf
ID: 6990670
Maybe the "-oi" should be "-i" in your sendmail call...

Other than this you can also use the MIME::Tools module like this:

---
use MIME::Entity;

my $address_string = 'me@ix.netcom.com';
my $recipient_address = 'you@is.netcom.com';
  # mysite.com is no valid email address !

my $data_string = <<eof;

[form info here]

eof

my $mail = MIME::Entity->build(
  'Encoding'     => 'quoted-printable',
  'From'         => $address_string,
  'To'           => [ $recipient_address ],
  'Subject'      => "Whatever your subject is",
  'Data'         => $data_string
);

open MAIL, "| /usr/sbin/sendmail -t -i" or die "open: $!";
$top->head->fold;
$top->print(\*MAIL);
close MAIL;

Hope that helps...Andy

0
 
LVL 1

Accepted Solution

by:
andy_wolf earned 55 total points
ID: 6990672
Well the module must be installed therefor which is really easy if you have root access to the system:

> perl -MCPAN -e 'install MIME::Tools'

If you have no root access ask your system administrator to install this module for you if it is not already available. This module is very useful because it handles a lot of work in the background to provide a mail in correct/RFC-conforming format...

Andy
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7116821
Have you been helped here or is more needed?
Moondancer - EE Moderator
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl, group, sort, count question 6 132
perl split by | 2 97
git fat pull happens nothing in centos 6.3 python 2.6.6 33 215
Perl script not writing to .csv file 6 109
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question