email - "Incomplete Headers" with PHP's mail() function -


[sat apr 25 04:18:46.660552 2015] [fastcgi:error] [pid 11271:tid 140464355243776] [client 95.87.236.146:63037] fastcgi: comm server "/usr/lib/cgi-bin/php5-fcgi-domain.cc" aborted: idle timeout (30 sec), referer: http://domain.cc/login/restore_session.php?redirect=yes [sat apr 25 04:18:46.660673 2015] [fastcgi:error] [pid 11271:tid 140464355243776] [client 95.87.236.146:63037] fastcgi: incomplete headers (0 bytes) received server "/usr/lib/cgi-bin/php5-fcgi-domain.cc", referer: http://domain.cc/login/restore_session.php?redirect=yes 

i getting these errors in error.log file. happens when try send email mail() function:

$to = $ticket->email; $subject = "x support"; $message = "we have answered support ticket! here our message: \n\n-------------\n\n" . $text . "\n\n-------------\n\nif wish reply, please visit http://domain.cc/support.php"; $headers = "from: noreply@domain.cc\r\n" . "reply-to: noreply@domain.cc\r\n" . "x-mailer: php/" . phpversion() . "\r\n"; $headers .= "cc: noreply@domain.cc\r\n"; $headers .= "mime-version: 1.0\r\n"; $headers .= "content-type: text/html; charset=iso-8859-1\r\n"; $result = mail($to, $subject, $message, $headers); 

i'm calling code ajax , result when click "send reply", page hangs , 500 error response after 30 seconds. weird thing code used work fine few months.

edit: forgot mention - emails delivered anyway.

in setting, connection between apache , php done variant of cgi, fastcgi. that's why you're seeing fastcgi:error in logs. when apache receives request url that's php file, "my-site.tld/index.php", passes request along php. php "does it's thing" , sends output. php output gets send out apache client did request.

but apache doesn't wait forever php answer. there's "idle timeout" of 30 seconds. after that's gone by, apache assumes php won't sending answer anymore. that's what's happening in case, can see in comm server "/usr/lib/cgi-bin/php5-fcgi-domain.cc" aborted: idle timeout (30 sec). apache doesn't have send client did request, not (complete) headers, because received 0 bytes php: incomplete headers (0 bytes) received server "/usr/lib/cgi-bin/php5-fcgi-domain.cc"

the conclusion is: reason, execution of code takes php longer timeout of 30 seconds. triggers apache think "i've waited long enough, there won't answer". next question should imho, makes php code take long.

one possible approach remove/comment out parts of code , see if rest gets executed within 30 seconds limit. still break timeout limit when $to = $ticket->email;? next step, still break limit when first 2 lines , forth. if that's feasable approach depends on details of setting , work environment.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -