I have a strange issue.
The mails sent by php mail() function are not sent instantaneously.
PHP Code:
$Name = "Da Duder"; //senders name
$email = "email@adress.com"; //senders e-mail adress
$recipient = "email@adress.com"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
if(mail($recipient, $subject, $mail_body, $header))
echo "success";
else
echo "Failed";
This code prints out "Success", however the mail is not sent. It takes a long time before it appears in the inbox. If I restart the sendmail
Code:
service sendmail restart
I get all the pending emails.
However if i send email from command line
Code:
echo "Subject: test" | sendmail -v test@example.com
the mail is sent out instantaneously.
The contents of the mail log when a mail is sent from php
Code:
Nov 23 07:50:53 hostname sendmail[9658]: pANCorMN009658: from=apache, size=121, class=0, nrcpts=1, msgid=<201111231250.pANCorMN009658@hostname>, relay=apache@localhost
Nov 23 07:50:53 hostname sendmail[9658]: pANCorMN009658: to=test@example.com, delay=00:00:00, mailer=esmtp, pri=30121, dsn=4.4.3, stat=queued
however the mail queue is empty as displyed by
I get this response for the above command
Code:
/var/spool/mqueue is empty
Total requests: 0
Update:
All the emails that are pending will be sent at once.
Any clues?
Thanks in advance