Solved

script isn't sending email to me

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Port 80 requests 16 86
collecting information 2 135
Help with a Script that will rename a file when it's not longer being written to 5 68
File Find regex problem 4 60
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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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 is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

930 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

12 Experts available now in Live!

Get 1:1 Help Now