Bilashi Sahu wrote: > Hi, > > I wrote following program to send an email to my email id, looks like it is > running. But when I checked my mailbox, does not find any email. > Can anybody help me to find if anything I am missing here. > I appreciate for your reply. > > thanks, > > Bilashi > > > 1. > sendmail.pl > ============ > > #!/home/y/bin/perl -w > > > # set up email message > my $sendmail = "/usr/sbin/sendmail -t -v"; > my $reply_to = "Reply-to: [email protected]"; > my $subject = "Subject: Testmail"; > my $content = "Hello and how are you doing? This is the message body"; > > > > my $to = "To: [email protected]"; > open(SENDMAIL, "|$sendmail") or die "Cannot send mail: $!"; > print SENDMAIL "$reply_to\n"; > print SENDMAIL "$subject\n"; > print SENDMAIL "$to\n"; > print SENDMAIL "Content-type: text/plain\n\n"; > print SENDMAIL "$content\n"; > print SENDMAIL "\.\n"; > close(SENDMAIL);
Nothing obvious there (not sure if the content type is needed), try this alternate version just to see if it makes any difference: #!/home/y/bin/perl -- use strict; use warnings; my $sendmail = '/usr/sbin/sendmail -t -oi'; my $addr = '[email protected]'; my $subject = 'Testmail'; my $content = 'Hello and how are you doing? This is the message body'; open SENDMAIL, "|$sendmail" or die "$sendmail: $! ($^E)"; print SENDMAIL "To: $addr\n"; print SENDMAIL "From: $addr\n"; print SENDMAIL "Reply-to: $addr\n"; print SENDMAIL "Subject: $subject\n"; print SENDMAIL "\n"; print SENDMAIL "$content\n"; print SENDMAIL "\n"; close SENDMAIL; __END__ _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
