I use PHP to send an email like this:
mail($email_recipient,$mail_subject,$mail_body,"From: $email_sender\r\nReply-to: $email_sender\r\n");
The $mail_body is perhaps 1kb. $email_recipient = $email_sender = "myaddress@gmail.com".
This takes 20 seconds to send on a mac os x server.
Here is some data from phpinfo:
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
SMTP localhost localhost
smtp_port 25 25
Here is a snippet from my 'man sendmail' showing that it is really postfix underneath:
sendmail - Postfix to Sendmail compatibility interface
Server load avg in top is 0.25
What is the problem and how do I make this faster?
I would assume a reasonable time for simply queueing an email would be in the range of milliseconds instead of 20 seconds.
--
Some DNS timing tests which look ok to me:
;; Query time: 1 msec
real 0m0.005s
user 0m0.001s
sys 0m0.003s
admin$ dscacheutil -flushcache
admin$ time dig gmail.com MX
[...]
;; Query time: 1 msec
[...]
real 0m0.006s
user 0m0.001s
sys 0m0.003s
admin$
--
Some mail timing:
admin$ echo test | time mail -s subject2 myaddress@gmail.com
0.00 real 0.00 user 0.00 sys
admin$ time php -r 'mail("myaddress@gmail.com","sub","body","From: myaddress@gmail.com\r\nRelply-to: myaddress@gmail.com\r\n");'
real 0m4.033s
user 0m0.015s
sys 0m1.523s
So for some reason, php mail takes significantly more time than normal mail from the shell.