advait has asked for the wisdom of the Perl Monks concerning the following question:

Hi All I am using the following code to send a email . The script runs well and shows the last conformation message. But I dont receive the email in my account. I checked the error log on server that is also not showing any error...Pleeeeeeeeeease help
#!/usr/bin/perl use CGI; my $query = new CGI; my $sendmail = "/usr/sbin/sendmail -t"; my $reply_to = "Reply-to: vidhu4000\@yahoo.com\n"; my $subject = "Subject: Confirmation of your submission\n"; my $content = "Thanks for your submission."; my $to = "vidhu4000\@yahoo.com"."\n"; my $file = "../output/tmp/subscribers.txt"; open (FILE, ">>$file") or die "Cannot open $file: $!"; print FILE $to."\n"; close(FILE); my $send_to = "To: vidhu4000\@yahoo.com"; open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!"; print SENDMAIL $reply_to; print SENDMAIL $subject; print SENDMAIL $send_to; print SENDMAIL "Content-type: text/plain\n\n"; print SENDMAIL $content; close(SENDMAIL); print $query->header; print "Confirmation of your submission will be emailed to you.";

Replies are listed 'Best First'.
Re: sendmail not sending email...please help
by wind (Priest) on Jul 11, 2007 at 22:25 UTC
    Refactoring your code to model after perlfaq9 How do I send mail?
    #!/usr/bin/perl use CGI; use strict; use warnings; my $query = new CGI; my $sendmail = "/usr/sbin/sendmail -t"; my $reply_to = q{vidhu4000@yahoo.com}; my $to = q{vidhu4000@yahoo.com}; my $subject = q{Confirmation of your submission}; my $content = "Thanks for your submission."; # Log Subscription my $subscriptions = "../output/tmp/subscribers.txt"; open(SUBSCRIPTIONS, ">>$subscriptions") or die "Cannot open $subscript +ions: $!"; print SUBSCRIPTIONS $to."\n"; close(SUBSCRIPTIONS); # Send Confirmation Email open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!"; print SENDMAIL <<"END_MAIL"; Reply-to: $reply_to Subject: $subject To: $to Content-type: text/plain $content END_MAIL close(SENDMAIL) or warn "sendmail didn't close nicely"; # HTML Confirmation print $query->header; print "Confirmation of your submission will be emailed to you.";
    - Miller
      This is also not working. I am running the script on ubuntu. I have already installed the sendmail but I might need some other changes in settings...any suggestions?
        Someone is giving error message, find it out
Re: sendmail not sending email...please help
by almut (Canon) on Jul 11, 2007 at 21:44 UTC

    You probably want a linefeed at the end of the To: header (i.e. $send_to). Otherwise the address will merge with the next line and yield an invalid email "vidhu4000@yahoo.comContent-type:".

      Nope this didnt work.......I am running the script on ubuntu...may be I need to change some settings I have already installed sendmail on ubuntu....any suggestions?