public function emailLicenseAP() { $app = new Application($this->app_id); // Create a random boundary $boundary = base64_encode(md5(rand())); $headers = "From: {$app->from_email}\n"; $headers .= "X-Mailer: PHP/" . phpversion() . "\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"{$boundary}\"\n"; $headers .= "Content-Transfer-Encoding: 7bit\n\n"; $headers .= "This is a MIME encoded message.\n\n"; $headers .= "--{$boundary}\n"; $headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; $headers .= "Content-Transfer-Encoding: 7bit\n\n"; $headers .= $app->getBody($this) . "\n\n\n"; $headers .= "--{$boundary}\n"; $headers .= "Content-Type: application/octet-stream; name=\"{$app->license_filename}\"\n"; $headers .= "Content-Transfer-Encoding: base64\n"; $headers .= "Content-Disposition: attachment\n\n"; $headers .= chunk_split(base64_encode($this->license)) . "\n"; $headers .= "--{$boundary}--"; mail($this->payer_email, $app->email_subject, '', utf8_encode($headers)); }
public function emailLicenseCF() { require 'Mail.php'; require 'Mail/mime.php'; $app = new Application($this->app_id); $text = $app->getBody($this); $html = "<html><body>" . $text . "</body></html>"; $crlf = "\n"; $hdrs = array('From' => $app->from_email, 'Subject' => $app->email_subject); $mime = new Mail_mime($crlf); $mime->setTXTBody($text); $mime->setHTMLBody($html); // $mime->addAttachment($file, 'text/plain'); //do not ever try to call these lines in reverse order $body = $mime->get(); $hdrs = $mime->headers($hdrs); $smtp =& Mail::factory('smtp', array('host' => SMTP_HOST, 'port' => SMTP_PORT, 'auth' => true, 'username' => SMTP_USERNAME, 'password' => SMTP_PASSWORD)); $mail = $smtp->send("{$this->first_name} {$this->last_name} <" . $this->payer_email . ">", $hdrs, $body); if (PEAR::isError($mail)) { echo "<p>" . $mail->getMessage() . "</p>"; } else { echo "<p>Message successfully sent!</p>"; } }