$host_url = "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname(dirname($_SERVER['PHP_SELF'])), '/\\');
    $pdf_file = "mpdf/pdfs/sub_contractor_report.pdf";
    @unlink($pdf_file);
    @shell_exec("rm -rf " . $pdf_file);
    $emailBody_pdf = str_replace("<img src='{$host_url}", "<img src='", str_replace("<img src='{$host_url}/", "<img src='", str_replace("<img src=\"{$host_url}/", "<img src=\"", $email_message)));
    preg_match_all("/<img src=[\"\\'](.*?)[\"\\']/i", $emailBody_pdf, $array);
    for ($i = 0; $i < count($array[1]); $i++) {
        if (!file_exists($array[1][$i])) {
            $emailBody_pdf = str_replace($array[1][$i], "", $emailBody_pdf);
        }
    }
    $mpdf = new mPDF('c');
    $mpdf->WriteHTML($emailBody_pdf);
    $mpdf->Output($pdf_file);
    $subject = "Subcontractor Reports for " . date("m/d/Y", time() - 3600);
    $attachMailer = new attach_mailer("Paxis Group", "*****@*****.**", $companyAdminEmails, $cc = "", $bcc = "*****@*****.**", $subject, $email_message);
    if (file_exists($pdf_file)) {
        $attachMailer->create_attachment_part($pdf_file, "attachment", "application/pdf");
    }
    $attachMailer->process_mail();
    //mail($companyAdminEmails,"Subcontractor Reports for ".date("m/d/Y",time()-3600),$email_message,$array_emails[$i]['headers']) or die("Error: There was an error sending mails");
    //@mail("*****@*****.**","Subcontractor Reports for " . date("m/d/Y",time()-3600),$email_message,$array_emails[0]['headers']) or die("Error: There was an error sending mails");
}
$query = "UPDATE subcontractor_emails SET sent = 1";
$subcontractor_emails_obj->customExecuteQuery($query);
$query = "SELECT COUNT(*) AS count_emails FROM subcontractor_emails WHERE sent = 1";
$array_sub_contractor_emails = $subcontractor_emails_obj->customFetchQuery($query);
if ($array_sub_contractor_emails[0]['count_emails'] > 3000) {
    $query = "DELETE FROM subcontractor_emails WHERE sent = 1";
    $subcontractor_emails_obj->customExecuteQuery($query);
}
<?php

require "attach_mailer_class.php";
//include ("classes/upload/upload_class.php");
// this class is used for the file upload, download at http://www.finalwebsites.com/snippets.php?id=7
// if you need assisstance about using this upload class, check the provided documentation
$msg = "";
$max_size = 1024 * 250;
// the max. size for uploading
//$my_upload = new file_upload;
if (isset($_POST['Submit'])) {
    $my_mail = new attach_mailer($name = $_POST['from_name'], $from = $_POST['from_email'], $to = $_POST['mail_to'], $cc = "", $bcc = "", $subject = $_POST['mail_subject']);
    $my_mail->text_body = $_POST['mail_body'];
    $full_path = 'image.gif';
    $my_mail->add_attach_file($full_path);
    $my_mail->process_mail();
    //    // upload part
    //    $my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
    //    $my_upload->the_file = $_FILES['upload']['name'];
    //    $my_upload->http_error = $_FILES['upload']['error'];
    //    if ($my_upload->upload()) {
    //        $full_path = $my_upload->upload_dir . $my_upload->file_copy;
    //        $my_mail->add_attach_file($full_path);
    //        $my_mail->process_mail();
    //        $my_upload->del_temp_file($full_path); // the file is not needed anymore
    //    }
    $msg .= $my_mail->get_msg_str();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<?php

require "attach_mailer_class.php";
$test = new attach_mailer($name = "Olaf", $from = "*****@*****.**", $to = "*****@*****.**", $cc = "", $bcc = "", $subject = "html mail with two images and att.");
//$test->add_html_image("image.gif");
//$test->add_html_image("vcss.png");
//$test->add_attach_file("ip2nation.zip");
$test->html_body = file_get_contents("html_attachment.htm");
$test->text_body = strip_tags($test->html_body, "<a>");
$test->process_mail();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Attachment Mailer example script</title>
    </head>

    <body>
        <h2>Attachment Mailer HTML example</h2>
        <p>This is a HTML example mail script using html code with inline attachments (images) and one regular attatchment. </p>
        <p style="color:#FF0000;"><?php 
echo $test->get_msg_str();
?>
</p>
    </body>
</html>
Ejemplo n.º 4
0
 public function sendEmailReport($propertyEmails, $propertyName, $propertyAddress, $propertyStatus, $propertyCommunity, $propertyType, $propertyJobType, $generalComments, $reportId, $mysqli)
 {
     $mailto = $propertyEmails;
     $mailSubject = 'Report for ' . $propertyCommunity . ", " . $propertyName;
     $host_url = "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname(dirname($_SERVER['PHP_SELF'])), '/\\');
     $replace_title = "<a href='" . $host_url . "/view_report.html?reportId=" . $reportId . "'>" . $mailSubject . "</a>";
     $searchArray = array('__PROPERTYCOMMUNITY__', '__PROPERTYNAME__', '__PROPERTYTYPE__', '__PROPERTYJOBTYPE__', '__ADDRESS__', '__REPORTDATE__', '__STATUS__', '__REPORTEDBY__', '__ROOMS__', '__GENERALCOMMENTS__');
     $replaceArray = array($propertyCommunity, $propertyName, $propertyType, $propertyJobType, $propertyAddress, date('m/d/Y g:ia'), $propertyStatus == 1 ? 'Open' : 'Closed/Archived', $_SESSION['user_firstname'] . ' ' . $_SESSION['user_lastname'], $this->roomsEmailBody, $generalComments);
     $emailBody = file_get_contents(dirname(dirname(__FILE__)) . '/email_template/report.tpl');
     $emailBody = str_replace($searchArray, $replaceArray, $emailBody);
     $emailBody = str_replace($mailSubject, $replace_title, $emailBody);
     $host_url = "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname(dirname($_SERVER['PHP_SELF'])), '/\\');
     $emailBody = str_replace('__HOST__', $host_url, $emailBody);
     $pdf_file = "../mpdf/pdfs/report.pdf";
     @unlink($pdf_file);
     @shell_exec("rm -rf " . $pdf_file);
     $emailBody_pdf = str_replace("<img src='{$host_url}", "<img src='..", str_replace("<img src=\"{$host_url}", "<img src=\"..", $emailBody));
     preg_match_all("/<img src=[\"\\'](.*?)[\"\\']/i", $emailBody_pdf, $array);
     for ($i = 0; $i < count($array[1]); $i++) {
         if (!file_exists($array[1][$i])) {
             $emailBody_pdf = str_replace($array[1][$i], "", $emailBody_pdf);
         }
     }
     $mpdf = new mPDF('c');
     $mpdf->WriteHTML($emailBody_pdf);
     $mpdf->Output($pdf_file);
     $mailHeaders = "From: Paxis Group <*****@*****.**> \r\n";
     $mailHeaders .= "Reply-To: Paxis Group <*****@*****.**>\r\n";
     $mailHeaders .= "Return-Path: Paxis Group <*****@*****.**>\r\n";
     $mailHeaders .= "Bcc: Wendell Malpas <*****@*****.**>\r\n";
     $mailHeaders .= "X-Mailer: PHP v" . phpversion() . "\r\n";
     $mailHeaders .= "MIME-Version: 1.0\r\n";
     $mailHeaders .= "Content-Type: text/html; charset=utf-8";
     if ($_SESSION['user_type'] == 5) {
         $insertSubContractorSql = "INSERT INTO subcontractor_emails(emailAddress, subject, emailBody, headers, sent, timestamp) VALUES(?, ?, ?, ?, 0, NOW())";
         if ($insertSubContractorStmt = $mysqli->prepare($insertSubContractorSql)) {
             $insertSubContractorStmt->bind_param("ssss", $mailto, $mailSubject, $emailBody, $mailHeaders);
             if ($insertSubContractorStmt->execute()) {
                 return true;
             } else {
                 return false;
             }
         }
     } else {
         $attachMailer = new attach_mailer("Paxis Group", "*****@*****.**", $mailto, $cc = "", $bcc = "*****@*****.**", $mailSubject, $emailBody);
         if (file_exists($pdf_file)) {
             $attachMailer->create_attachment_part($pdf_file, "attachment", "application/pdf");
         }
         return $attachMailer->process_mail();
         //return mail($mailto, $mailSubject, $emailBody, $mailHeaders);
     }
 }
<?php

error_reporting(E_ALL);
require "attach_mailer_class.php";
$test = new attach_mailer($name = "Olaf", $from = "*****@*****.**", $to = "*****@*****.**", $cc = "", $bcc = "", $subject = "Test text email with attachments");
$test->text_body = "...Some body text\n\n the admin";
//$test->add_attach_file("image.gif");
//$test->add_attach_file("ip2nation.zip");
$test->process_mail();
$to = '*****@*****.**';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: krunal48@gmail.com' . "\r\n" . 'Reply-To: krunal48@gmail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
Ejemplo n.º 6
0
<?php

include_once $_SERVER['DOCUMENT_ROOT'] . "/classes/upload/upload_class.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/classes/attach_mailer/attach_mailer_class.php";
$error = '';
if (isset($_POST['Submit'], $_FILES['upload'])) {
    $my_mail = new attach_mailer('MyName', '*****@*****.**', '*****@*****.**', '', '', 'test mail multi att.');
    $my_mail->text_body = 'Hello World';
    $num_files = count($_FILES['upload']['name']);
    for ($i = 0; $i < $num_files; $i++) {
        if ($_FILES['upload']['name'][$i] != '') {
            $my_upload = new file_upload();
            $my_upload->upload_dir = $_SERVER['DOCUMENT_ROOT'] . "/files/multi/";
            $my_upload->extensions = array(".png", ".jpg", ".gif");
            $my_upload->the_temp_file = $_FILES['upload']['tmp_name'][$i];
            $my_upload->the_file = $_FILES['upload']['name'][$i];
            $my_upload->http_error = $_FILES['upload']['error'][$i];
            $my_upload->replace = "n";
            if ($my_upload->upload()) {
                $full_path = $my_upload->upload_dir . $my_upload->file_copy;
                $my_mail->add_attach_file($full_path);
                $error .= 'File &quot;' . $my_upload->file_copy . '&quot; uploaded<br />';
            } else {
                break;
                $error = 'Error uploading file(s)';
            }
        }
    }
    if ($my_mail->process_mail()) {
        $error .= 'Mail send!';
    } else {