Click to See Complete Forum and Search --> : basic mail problem, not sending


kevinmcqueen
03-26-2009, 05:18 PM
Hi,

Not really up to scratch on perl, but there has been a problem with our site, since March 13, we've had no registrations, and upon testing the registration form, think we've found out why.

The email that is supposed to send, to validate registration is not sending.

A basic overview of the code is below,

my $sendmail = '/usr/lib/sendmail';

open (MAIL, "|$sendmail -t") or die "Can't open $sendmail: $!";
print MAIL "To: $mail1\n";
print MAIL "From: registrations\@ukdirt.co.uk\n";
print MAIL "Subject: UK-Dirt Registration - Response Required\n\n";
print MAIL "test\n";
close(MAIL);

Anyone any idea's why its not sending?

Sixtease
03-27-2009, 04:02 AM
Well, you might try the sendmail program from console and see what happens. If it sends a mail, then the error is somewhere else. If not, then your sendmail got broken. Be sure to test it under the same user that runs the HTTP server.

The text entered into the console could look something like:
su apache
<password>
/usr/lib/sendmail -t
To: recipient@email.foo
From: sender@email.foo
Subject: foo bar

Message body. Message body. Message body.
<ctrl+d to end the input>

winracer
04-01-2009, 04:26 PM
take this code below and copy to file called sendmailtest.pl


#!/usr/bin/perl
# This is a simple script to test sendmail.
# Replace "me" with a from address and "mydom.com" with the #sending domain.
# Replace "you" with a username to send to and "yourdom.com" #with the recipient's domain name.
# Upload this to the public_html folder as mailtest.pl and CHMOD it to 755
print "Content-type: text/plain\n\n";
unless(open (MAIL, "|/usr/sbin/sendmail -t")) {
print "error.\n";
warn "Error starting sendmail: $!";
}
else{
print MAIL "From: registrations\@ukdirt.co.uk\n";
print MAIL "To: youre-mail\@yordomain.com\n";
print MAIL "Subject: test subject from sendmail2.pl test\n\n";
print MAIL "Perl Sendmail is working, please check your code.";
close(MAIL) || warn "Error closing mail: $!";

}




in the to put a good e-mail address, drop file on your server and runit at yourdomain/sendmailtest.pl and see if it send you and e-mail.

svidgen
04-01-2009, 04:48 PM
As far as I know, sendmail won't complain if the message cannot be sent. You can type garbage into sendmail and it won't report a single error to STDOUT. So, the first thing you need to do is check your mail log--probably /var/log/mail.log.

For example, when I try to use sendmail from my home connection, sendmail reports no errors. However, my mail log contains entries that end in Operation time out, indicating that the destination mail server could not be reached--in my case, due to my ISP's SMTP filtering.

If the mail log doesn't show any errors, you need to check the mailbox for the local user (apache or www). If this is the case, you'll probably need to cat /var/mail/www or /var/mail/apache.