I am trying to run the async task using fsockopen in PHP. Actually I am sending an email with the PHPMailer library in Codeigniter. neither I am getting any error nor receiving an email with the following code...
public function sendingemail($mailer_admin_email,$mailer_sender_mail,$mailer_site_title,$mailer_subject,$mailer_message)
{
$url = "someurl.com/handleasyncprocess/sendemail";
$params = array(
'mailer_admin_email' => $mailer_admin_email,
'mailer_sender_mail' => $mailer_sender_mail,
'mailer_site_title' => $mailer_site_title,
'mailer_subject' => $mailer_subject,
'mailer_message' => $mailer_message,
);
$post_string = http_build_query($params);
$parts = parse_url($url);
$errno = 0;
$errstr = "";
$ip = "**.**.**.**";
$fp = fsockopen($ip, isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 30);
if(!$fp)
{
echo "Some thing Problem";
}
$out = "POST ".$parts['path']." HTTP/1.1\r\n";
$out.= "Host: ".$ip."\r\n";
$out.= "Content-Type: application/x-www-form-urlencoded\r\n";
$out.= "Content-Length: ".strlen($post_string)."\r\n";
$out.= "Connection: Close\r\n\r\n";
if (isset($post_string)) $out.= $post_string;
fwrite($fp, $out);
fclose($fp);
}
Please help!!
You can use this code