Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sendmail Probs...

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Ok, can some one please give me a pointer as to why this code isn't working? As far as I can see it should, but it doesn't :(

Code:
open(MAIL, "|$sendmail -t") || die &error;
print MAIL "To: $email  \n";
print MAIL "From: $email \n";
print MAIL "Reply-to: $email \n";
print MAIL "Subject: Your Sites Variables \n\n";
print MAIL "All of the major variables that you will find with your hosting / site are listed below. The IP address that sent it was $ip....\n\n";
print MAIL "\n\n";
close(MAIL);

Thanks

Andy
 
Andy,

It looks fine..... what does it do? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Nothing :( No errors, no calling of the error sub, no anything :( Not even anything in the error log!

Andy
 
Maybe it's cause of the sendmail variable. Ask your host about your sendmail root. But usually, it's one of these:

open(MAIL, "|/usr/lib/sendmail -t");

or

open(MAIL, "|/usr/sbin/sendmail -t"); -Aaron
 
You do have a subroutine named "error", don't you? The "die &error" part will try to invoke a subroutine named error if the open does not work. If you don't have one, the program will abort. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Yeah, I have a sub called error. It is;

sub error
{
print header;
print "There was a prob opening $sendmail";
}

Thanks. Any other ideas?

Andy
 
Obvious I know, but could it be possible that the $email variable is wrong? Perhaps you could post the whole script - sounds like it's someting else in the script other than that routine.

Matt.
 
Here's a good, quick way to make sure that what is getting sent to sendmail is what you want. Change the open statement temporarily to this:
Code:
$| = 1; # flush stdout after every print
print "Content-type: text/plain\n\n";
open(MAIL, "|cat") || die &error;
That will cause your sendmail output to be displayed to your browser, and you can check that the email message is formatted properly and everything is there.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top