Solved

script isn't sending email to me

Posted on 2002-04-27
5
157 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now