$message = str_replace('%currency%', $currency, $message); $message = str_replace('%amount%', number_format($_POST['amount'], 2, '.', ', '), $message); $issued_date = explode('-', $data['issued_on']); $issued_timestamp = $issued_date[0] . $issued_date[1] . $issued_date[2]; $message = str_replace('%purchased_on%', date('j M, Y', $issued_timestamp), $message); $body .= $message . "\n"; $body .= '--yel_mail_sep_alt_' . $invoice . "--\n\n"; $body .= '--yel_mail_sep_' . $invoice . "\n"; $body .= 'Content-Type: application/pdf; name="yel_invoice_' . pad($invoice, 11, '0') . '.pdf"' . "\n"; $body .= 'Content-Transfer-Encoding: base64' . "\n"; $body .= 'Content-Disposition: attachment' . "\n"; $body .= $attachment . "\n"; $body .= '--yel_mail_sep_' . $invoice . "--\n\n"; mail($employer->get_email_address(), $subject, $body, $headers); // $handle = fopen('/tmp/email_to_'. $employer->get_email_address(). '.txt', 'w'); // fwrite($handle, 'Subject: '. $subject. "\n\n"); // fwrite($handle, $body); // fclose($handle); unlink($GLOBALS['data_path'] . '/subscription_invoices/' . $invoice . '.pdf'); // 3. unsuspend and extend the subscription if ($employer->unsuspend_subscription() === false) { echo 'ko'; exit; } if ($employer->extend_subscription($_POST['period']) === false) { echo 'ko'; exit; } echo 'ok'; exit; }