clearAttachments() public method

Clear all filesystem, string, and binary attachments.
public clearAttachments ( ) : void
return void
Example #1
5
 /**
  * Inner mailer initialization from set variables
  *
  * @return void
  */
 protected function initMailFromSet()
 {
     $this->mail->setLanguage($this->get('langLocale'), $this->get('langPath'));
     $this->mail->CharSet = $this->get('charset');
     $this->mail->From = $this->get('from');
     $this->mail->FromName = $this->get('fromName') ?: $this->get('from');
     $this->mail->Sender = $this->get('from');
     $this->mail->clearAllRecipients();
     $this->mail->clearAttachments();
     $this->mail->clearCustomHeaders();
     $emails = explode(static::MAIL_SEPARATOR, $this->get('to'));
     foreach ($emails as $email) {
         $this->mail->addAddress($email);
     }
     $this->mail->Subject = $this->get('subject');
     $this->mail->AltBody = $this->createAltBody($this->get('body'));
     $this->mail->Body = $this->get('body');
     // add custom headers
     foreach ($this->get('customHeaders') as $header) {
         $this->mail->addCustomHeader($header);
     }
     if (is_array($this->get('images'))) {
         foreach ($this->get('images') as $image) {
             // Append to $attachment array
             $this->mail->addEmbeddedImage($image['path'], $image['name'] . '@mail.lc', $image['name'], 'base64', $image['mime']);
         }
     }
 }
Example #2
0
 /**
  * @param bool $immediately
  * @return bool
  * @throws \phpmailerException
  */
 public function send($immediately = true)
 {
     $salida = $this->mail->Send();
     $this->mail->clearAddresses();
     $this->mail->clearAttachments();
     return $salida;
 }
Example #3
0
 /**
  * Miscellaneous calls to improve test coverage and some small tests.
  */
 public function testMiscellaneous()
 {
     $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
     $this->Mail->addCustomHeader('SomeHeader: Some Value');
     $this->Mail->clearCustomHeaders();
     $this->Mail->clearAttachments();
     $this->Mail->isHTML(false);
     $this->Mail->isSMTP();
     $this->Mail->isMail();
     $this->Mail->isSendmail();
     $this->Mail->isQmail();
     $this->Mail->setLanguage('fr');
     $this->Mail->Sender = '';
     $this->Mail->createHeader();
     $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
     $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
     $this->assertTrue($this->Mail->set('AllowEmpty', null), 'Null property set failed');
     $this->assertTrue($this->Mail->set('AllowEmpty', false), 'Valid property set of null property failed');
     //Test pathinfo
     $a = '/mnt/files/飛兒樂 團光茫.mp3';
     $q = PHPMailer::mb_pathinfo($a);
     $this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched');
     $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched');
     $this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched');
     $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_BASENAME), '飛兒樂 團光茫.mp3', 'Basename path element not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched');
     $a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3';
     $q = PHPMailer::mb_pathinfo($a);
     $this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched');
     $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched');
     $this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched');
     $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched');
     $this->assertEquals(PHPMailer::filenameToType('abc.jpg?xyz=1'), 'image/jpeg', 'Query string not ignored in filename');
     $this->assertEquals(PHPMailer::filenameToType('abc.xyzpdq'), 'application/octet-stream', 'Default MIME type not applied to unknown extension');
     //Line break normalization
     $eol = $this->Mail->LE;
     $b1 = "1\r2\r3\r";
     $b2 = "1\n2\n3\n";
     $b3 = "1\r\n2\r3\n";
     $this->Mail->LE = "\n";
     $t1 = "1{$this->Mail->LE}2{$this->Mail->LE}3{$this->Mail->LE}";
     $this->assertEquals($this->Mail->fixEOL($b1), $t1, 'Failed to normalize line breaks (1)');
     $this->assertEquals($this->Mail->fixEOL($b2), $t1, 'Failed to normalize line breaks (2)');
     $this->assertEquals($this->Mail->fixEOL($b3), $t1, 'Failed to normalize line breaks (3)');
     $this->Mail->LE = "\r\n";
     $t1 = "1{$this->Mail->LE}2{$this->Mail->LE}3{$this->Mail->LE}";
     $this->assertEquals($this->Mail->fixEOL($b1), $t1, 'Failed to normalize line breaks (4)');
     $this->assertEquals($this->Mail->fixEOL($b2), $t1, 'Failed to normalize line breaks (5)');
     $this->assertEquals($this->Mail->fixEOL($b3), $t1, 'Failed to normalize line breaks (6)');
     $this->Mail->LE = $eol;
 }
Example #4
0
File: Mailer.php Project: acp3/core
 /**
  * Resets the currently set mailer values back to there default values
  *
  * @return $this
  */
 public function reset()
 {
     $this->subject = '';
     $this->body = '';
     $this->htmlBody = '';
     $this->urlWeb = '';
     $this->mailSignature = '';
     $this->from = '';
     $this->recipients = null;
     $this->bcc = false;
     $this->attachments = [];
     $this->template = '';
     if ($this->phpMailer) {
         $this->phpMailer->clearAllRecipients();
         $this->phpMailer->clearAttachments();
     }
     return $this;
 }
Example #5
0
function save_lead()
{
    if ($_POST['submit']) {
        $user_name = $_POST['user_name'];
        if ($user_name == '') {
            $user_name = 'pathways';
        }
        $lead_name = $_POST['lead_name'];
        $lead_twitter = trim($_POST['lead_twitter']);
        $lead_phone = trim($_POST['lead_phone']);
        $lead_email = trim($_POST['lead_email']);
        $lead_twitter_noat = str_replace('@', '', $lead_twitter);
        $follow_up_date_time = strtotime($_POST['follow_up_date']);
        $follow_up_date = date('Y:m:d', $follow_up_date_time);
        $entry_date = date('Y-m-d H:i');
        include '../../../inc/connection.php';
        if (mysqli_fetch_array($result) == false) {
            echo '<p id="joinbutton">';
            echo 'You have no Leads :(.
				</p>';
        }
        // Insert into database
        $sql = "INSERT INTO leads (user_name, lead_name, lead_twitter, follow_up_date, entry_date, lead_phone, lead_email) VALUES ('{$user_name}','{$lead_name}','{$lead_twitter}','{$follow_up_date}','{$entry_date}','{$lead_phone}','{$lead_email}')";
        if (mysqli_query($con, $sql)) {
            $follow_up_date = date('l, M/j/Y @ h:i A', $follow_up_date_time);
            // NOTIFICATIONS
            $email_subject = '[LEAD] ' . $lead_twitter . ' - "' . $lead_name . '" was Received!';
            $email_body = 'We have an new lead.<br><br>' . $lead_name . '<br><br><hr><br>';
            $email_body .= 'Thank you for submitting your music to FREELABEL Studios! We are a collective of producers, designers, and musicians dedicated to producing the highest quality exclusive platform to launch new brands to an audience averaging at <u>8.2+ Million Impressions each month.</u> You will be the branded product behind the impression we make to the world.<br><br>You will need to complete your registration by creating your account at http://freelabel.net/submit/ to get booked on any of the upcoming projects, publications, interviews, & radio showcases on the FREELABEL Radio, Magazine, & TV Network. Feel free to give us a call or email if you have any questions.';
            $body_template = '								<style>
															html{
																width:100%;
															}
																body {
																	//background-image:url("' . $uploaded_file_path_http . '");
																	background-size:auto 100%;
																	background-position:center center;
																	background-color:#FE3F44;
																	color:#e3e3e3;
																	padding:0%;
																	margin:0%;
																	text-align:center;
																}
																#para_text {
																margin:1% auto;
																padding:1% 2%;
																font-size:100%;
															}
															#submission_info {
																background-color:#e3e3e3;
																color:#000000;
																width:90%;
																margin:auto;
																padding:2%;
																border-radius:10px;
															}
															#submission_info table, #submission_info tr,#submission_info td {
																margin:auto;
																color:#000;
															}
															a {
																//color:#FE3F44;
																color:#303030;
															}
															#email_photo {
															max-width:500px;
															margin:1% 0 3% 0;
															box-shadow:0px 0px 5px #303030;
														}
														#signature_block {
														margin: 4% auto;
														font-size:80%;

													}
												</style>
												<body>
													<img style="width:250px" src="http://freelabel.net/images/FREELABELLOGO.gif"><br>
													<img style="width:250px" src="http://freelabel.net/images/flheadblack.png"><br>

													<div id="para_text">
														<h1>' . $email_subject . '</h1>

														' . $email_body . "\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<hr>\n\t\t\t\t\t\t\t\t\t\t\t\t" . '<h2>LEAD INFORMATION:</h2>
														<div id="submission_info">
															<table>
																<tr>
																	<td>COMMENTS:</td>
																	<td>' . $lead_name . '</td>
																</tr>
																<tr>
																	<td>PHONE:</td>
																	<td>' . $lead_phone . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>FOLLOW UP // ENTRY DATE:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $follow_up_date . " // " . $entry_date . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>TWITTER:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $lead_twitter . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>EMAIL:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $lead_email . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br><br>\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div id='signature_block'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<u>FREELABEL Account Executive</u>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<br>c: (323) 601-8111<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\te: info@FREELABEL.net\n\n\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\nFREELABEL.net\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t</body>";
            $stafflist = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
            //foreach ($stafflist as $admin) {
            include '../../../mailer/PHPMailerAutoload.php';
            //Create a new PHPMailer instance
            $mail = new PHPMailer();
            // Set PHPMailer to use the sendmail transport
            $mail->isSendmail();
            //Set who the message is to be sent from
            $mail->setFrom('*****@*****.**', 'FL SALES');
            //Set an alternative reply-to address
            $mail->addReplyTo('*****@*****.**', 'Sales Administration');
            //Set the subject line
            $mail->Subject = $email_subject;
            //Read an HTML message body from an external file, convert referenced images to embedded,
            //convert HTML into a basic plain-text alternative body
            $mail->msgHTML($body_template);
            //Replace the plain text body with one created manually
            $mail->AltBody = $body_template;
            //Attach an image file
            //$mail->addAttachment('images/phpmailer_mini.png');
            //send the message, check for errors
            foreach ($stafflist as $admin) {
                //This iterator syntax only works in PHP 5.4+
                $mail->addAddress($admin, 'FREELABEL SUBMISSIONS');
                if (!empty($row['photo'])) {
                    $mail->addStringAttachment($row['photo'], 'YourPhoto.jpg');
                    //Assumes the image data is stored in the DB
                }
                if (!$mail->send()) {
                    echo "Mailer Error (" . str_replace("@", "&#64;", $admin) . ') ' . $mail->ErrorInfo . '<br />';
                    break;
                    //Abandon sending
                } else {
                    echo "Message sent to: " . $admin . "!<br>";
                    //echo "<br><br><br><br>".$body_template.'<br><br>';
                    echo "Message sent to :" . $admin . ' (' . str_replace("@", "&#64;", $admin) . ')<br />';
                }
                // Clear all addresses and attachments for next loop
                $mail->clearAddresses();
                $mail->clearAttachments();
            }
            echo "Entry Created Successfully! ";
            echo "<script>\n\t\t\t\t\t\t\t\t\t\t\tfunction newDoc()\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\twindow.location.assign(\"http://freelabel.net/?ctrl=leads#add\")\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tnewDoc()\n\t\t\t\t\t\t\t\t\t\t\t</script>";
            echo '<style>
					html {
					color:#fff;
					background-color:#303030;
					margin:10%;
					font-size:300%;
					font-family:sans-serif;
					}
					</style>';
            echo "Your LEAD has been Saved. Please stay updated!<br><br>Your Lead: <p id='sub_label' >" . $lead_name . '<br>TWITTER: ';
            echo $lead_twitter . " and you must follow up on: " . $follow_up_date . "</p><a href='http://freelabel.net/submit/#leads'>Return to Dashboard</a><br><br><br><br><br><br>";
        } else {
            echo "Error creating database entry: " . mysqli_error($con);
        }
    }
}
 /**
  * Send email(s).
  *
  * @since 2.5.0
  *
  * @param BP_Email $email Email to send.
  * @return bool|WP_Error Returns true if email send, else a descriptive WP_Error.
  */
 public function bp_email(BP_Email $email)
 {
     static $phpmailer = null;
     if ($phpmailer === null) {
         if (!class_exists('PHPMailer')) {
             require_once ABSPATH . WPINC . '/class-phpmailer.php';
             require_once ABSPATH . WPINC . '/class-smtp.php';
         }
         $phpmailer = new PHPMailer(true);
     }
     /*
      * Resets.
      */
     $phpmailer->clearAllRecipients();
     $phpmailer->clearAttachments();
     $phpmailer->clearCustomHeaders();
     $phpmailer->clearReplyTos();
     $phpmailer->Sender = '';
     /*
      * Set up.
      */
     $phpmailer->IsMail();
     $phpmailer->CharSet = bp_get_option('blog_charset');
     $phpmailer->Hostname = self::get_hostname();
     /*
      * Content.
      */
     $phpmailer->Subject = $email->get_subject('replace-tokens');
     $content_plaintext = PHPMailer::normalizeBreaks($email->get_content_plaintext('replace-tokens'));
     if ($email->get('content_type') === 'html') {
         $phpmailer->msgHTML($email->get_template('add-content'), '', 'wp_strip_all_tags');
         $phpmailer->AltBody = $content_plaintext;
     } else {
         $phpmailer->IsHTML(false);
         $phpmailer->Body = $content_plaintext;
     }
     $recipient = $email->get_from();
     try {
         $phpmailer->SetFrom($recipient->get_address(), $recipient->get_name(), false);
     } catch (phpmailerException $e) {
     }
     $recipient = $email->get_reply_to();
     try {
         $phpmailer->addReplyTo($recipient->get_address(), $recipient->get_name());
     } catch (phpmailerException $e) {
     }
     $recipients = $email->get_to();
     foreach ($recipients as $recipient) {
         try {
             $phpmailer->AddAddress($recipient->get_address(), $recipient->get_name());
         } catch (phpmailerException $e) {
         }
     }
     $recipients = $email->get_cc();
     foreach ($recipients as $recipient) {
         try {
             $phpmailer->AddCc($recipient->get_address(), $recipient->get_name());
         } catch (phpmailerException $e) {
         }
     }
     $recipients = $email->get_bcc();
     foreach ($recipients as $recipient) {
         try {
             $phpmailer->AddBcc($recipient->get_address(), $recipient->get_name());
         } catch (phpmailerException $e) {
         }
     }
     $headers = $email->get_headers();
     foreach ($headers as $name => $content) {
         $phpmailer->AddCustomHeader($name, $content);
     }
     /**
      * Fires after PHPMailer is initialised.
      *
      * @since 2.5.0
      *
      * @param PHPMailer $phpmailer The PHPMailer instance.
      */
     do_action('bp_phpmailer_init', $phpmailer);
     /** This filter is documented in wp-includes/pluggable.php */
     do_action_ref_array('phpmailer_init', array(&$phpmailer));
     try {
         return $phpmailer->Send();
     } catch (phpmailerException $e) {
         return new WP_Error($e->getCode(), $e->getMessage(), $email);
     }
 }
 /**
  * Initialisiert ein Objekt der Klasse PhpMailer und setzt die
  * Authentifizierung des Systems ein.
  * @param int $port pass a port number here
  * @param string $security an empty string or 'tls' or 'ssl'
  * @return \PHPMailer
  * @throws Exception if PHPMailer throws an exception
  */
 public static function initMailer($port = null, $security = null)
 {
     /** PhpMailer einbinden */
     require_once realpath(ROOT_PATH) . '/external_scripts/phpmailer/class.phpmailer.php';
     require_once realpath(ROOT_PATH) . "/external_scripts/phpmailer/class.smtp.php";
     $mail = new PHPMailer();
     // Vorformatierungen
     $mail->setLanguage('de');
     $mail->CharSet = 'utf-8';
     $mail->clearAttachments();
     $mail->clearAddresses();
     if (defined('SMTP_HOST') && strlen(SMTP_HOST) > 0) {
         // SMTP-Autorisierung
         $mail->isSMTP();
         $mail->Host = SMTP_HOST;
         if (defined('DEBUG_MODUS') && DEBUG_MODUS > 0) {
             $mail->SMTPDebug = 2;
         }
         if (!is_null($port)) {
             $mail->Port = $port;
         } elseif (defined('SMTP_PORT') && strlen(SMTP_PORT) > 0) {
             $mail->Port = SMTP_PORT;
         }
         if (defined('SMTP_USER') && strlen(SMTP_USER) > 0 && defined('SMTP_PASSWORD') && strlen(SMTP_PASSWORD) > 0) {
             $mail->SMTPAuth = true;
             $mail->Username = SMTP_USER;
             $mail->Password = SMTP_PASSWORD;
             if (!is_null($security)) {
                 $mail->SMTPSecure = $security;
             } elseif (defined("SMTP_SECURITY") && strlen(SMTP_SECURITY) > 0) {
                 $mail->SMTPSecure = SMTP_SECURITY;
             }
         } else {
             $mail->SMTPAuth = false;
         }
     } else {
         $mail->isSendmail();
     }
     return $mail;
 }
Example #8
0
function sola_nl_ajax_send($subscribers, $camp_id)
{
    $debug_start = (double) array_sum(explode(' ', microtime()));
    global $wpdb;
    global $sola_nl_camp_tbl;
    global $sola_nl_camp_subs_tbl;
    global $sola_nl_subs_tbl;
    global $sola_global_subid;
    global $sola_global_campid;
    if ($camp_id) {
        echo get_option("sola_currently_sending");
        if (!get_option("sola_currently_sending")) {
            if (get_option("sola_currently_sending") == "yes") {
                return "We are currently sending. Dont do anything";
            } else {
                update_option("sola_currently_sending", "yes");
            }
        } else {
            add_option("sola_currently_sending", "yes");
        }
        update_option("sola_currently_sending", "yes");
        $camp = sola_nl_get_camp_details($camp_id);
        if (isset($camp->reply_to)) {
            $reply = $camp->reply_to;
        }
        if (isset($camp->reply_to_name)) {
            $reply_name = stripslashes($camp->reply_to_name);
        }
        if (isset($camp->sent_from)) {
            $sent_from = $camp->sent_from;
        }
        if (isset($camp->sent_from_name)) {
            $sent_from_name = stripslashes($camp->sent_from_name);
        }
        if (empty($reply)) {
            $reply = get_option("sola_nl_reply_to");
        }
        if (empty($reply_name)) {
            $reply_name = get_option("sola_nl_reply_to_name");
        }
        if (empty($sent_from)) {
            $sent_from = get_option("sola_nl_sent_from");
        }
        if (empty($sent_from_name)) {
            $sent_from_name = get_option("sola_nl_sent_from_name");
        }
        // get option for either SMTP or normal WP MAil
        // split below based on above
        $saved_send_method = get_option("sola_nl_send_method");
        if ($saved_send_method == "1") {
            $headers[] = 'From: ' . $sent_from_name . '<' . $sent_from . '>';
            $headers[] = 'Content-type: text/html';
            $headers[] = 'Reply-To: ' . $reply_name . '<' . $reply . '>';
        } else {
            if ($saved_send_method >= "2") {
                $file = PLUGIN_URL . '/includes/phpmailer/PHPMailerAutoload.php';
                require_once $file;
                $mail = new PHPMailer();
                $mail->IsSMTP();
                $mail->SMTPAuth = true;
                $mail->SMTPKeepAlive = true;
                $port = get_option("sola_nl_port");
                $encryption = get_option("sola_nl_encryption");
                if ($encryption) {
                    $mail->SMTPSecure = $encryption;
                }
                $host = get_option("sola_nl_host");
                $mail->Host = $host;
                $mail->Username = get_option("sola_nl_username");
                $mail->Password = get_option("sola_nl_password");
                $mail->Port = $port;
                $mail->AddReplyTo($reply, $reply_name);
                $mail->SetFrom($sent_from, $sent_from_name);
                $mail->Subject = $camp->subject;
                $mail->SMTPDebug = 0;
            }
        }
        if ($subscribers) {
            foreach ($subscribers as $subscriber) {
                set_time_limit(600);
                $sub_id = $subscriber['sub_id'];
                $sub_email = $subscriber['sub_email'];
                echo $sub_email;
                $body = sola_nl_mail_body($camp->email, $sub_id, $camp->camp_id);
                $sola_global_subid = $sub_id;
                $sola_global_campid = $camp->camp_id;
                $body = do_shortcode($body);
                $body = sola_nl_replace_links($body, $sub_id, $camp->camp_id);
                /* ------ */
                //$check = sola_mail($camp_id ,$sub_email, $camp->subject, $body);
                if ($saved_send_method == "1") {
                    if (wp_mail($sub_email, $camp->subject, $body, $headers)) {
                        $check = true;
                    } else {
                        if (!$debug) {
                            $check = array('error' => 'Error sending mail to' . $sub_email);
                        } else {
                            $check = array('error' => "Failed to send email to {$sub_email}... " . $GLOBALS['phpmailer']->ErrorInfo);
                        }
                    }
                } else {
                    if ($saved_send_method >= "2") {
                        if (is_array($sub_email)) {
                            foreach ($sub_email as $address) {
                                $mail->AddAddress($address);
                            }
                        } else {
                            $mail->AddAddress($sub_email);
                        }
                        $mail->Body = $body;
                        $mail->IsHTML(true);
                        //echo "sending to $sub_email<br />";
                        if (!$mail->Send()) {
                            $check = array('error' => 'Error sending mail to ' . $sub_email);
                        } else {
                            $check = true;
                        }
                    }
                }
                if ($check === true) {
                    sola_update_camp_limit($camp_id);
                    $wpdb->update($sola_nl_camp_subs_tbl, array('status' => 1), array('camp_id' => $camp_id, 'sub_id' => $sub_id), array('%d'), array('%d', '%d'));
                    //echo "Email sent to $sub_email successfully <br />";
                } else {
                    sola_return_error(new WP_Error('sola_error', __('Failed to send email to subscriber'), 'Could not send email to ' . $sub_email));
                    //echo "<p>Failed to send to ".$sub_email."</p>";
                }
                $mail->clearAddresses();
                $mail->clearAttachments();
                $end = (double) array_sum(explode(' ', microtime()));
                echo "<br />processing time: " . sprintf("%.4f", $end - $debug_start) . " seconds<br />";
                //$check = sola_nl_send_mail_via_cron($camp_id,$sub_id,$sub_email);
                //if ( is_wp_error($check)) sola_return_error($check);
            }
        } else {
            /* do nothing, reached limit */
        }
        if ($saved_send_method >= "2") {
            $mail->smtpClose();
        }
        $end = (double) array_sum(explode(' ', microtime()));
        echo "<br />processing time: " . sprintf("%.4f", $end - $debug_start) . " seconds<br />";
        update_option("sola_currently_sending", "no");
        sola_nl_done_sending_camp($camp_id);
    } else {
        echo "<br />nothing to send at this time<br />";
    }
}
Example #9
0
/**
 * Send an email using phpmailer
 *
 * @param string $from       From address
 * @param string $from_name  From name
 * @param string $to         To address
 * @param string $to_name    To name
 * @param string $subject    The subject of the message.
 * @param string $body       The message body
 * @param array  $bcc        Array of address strings
 * @param bool   $html       Set true for html email, also consider setting
 *                           altbody in $params array
 * @param array  $files      Array of file descriptor arrays, each file array
 *                           consists of full path and name
 * @param array  $params     Additional parameters
 * @return bool
 */
function phpmailer_gmail_send($from, $from_name, $to, $to_name, $subject, $body, array $bcc = NULL, $html = false, array $files = NULL, array $params = NULL)
{
    static $phpmailer;
    // Ensure phpmailer object exists
    if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) {
        require_once elgg_get_plugins_path() . '/phpmailer_gmail/vendors/phpmailer/PHPMailerAutoload.php';
        $phpmailer = new PHPMailer();
    }
    if (!$from) {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'from'));
    }
    if (!$to && !$bcc) {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'to'));
    }
    if (!$subject) {
        throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'subject'));
    }
    // set line ending if admin selected \n (if admin did not change setting, null is returned)
    if (elgg_get_plugin_setting('nonstd_mta', 'phpmailer')) {
        $phpmailer->LE = "\n";
    } else {
        $phpmailer->LE = "\r\n";
    }
    ////////////////////////////////////
    // Format message
    $phpmailer->clearAllRecipients();
    $phpmailer->clearAttachments();
    // Set the from name and email
    //$phpmailer->From = $from;
    //$phpmailer->FromName = $from_name;
    //Set who the message is to be sent from
    $phpmailer->setFrom($from, $from_name);
    //Set an alternative reply-to address
    $phpmailer->addReplyTo($from, $from_name);
    // Set destination address
    if (isset($to)) {
        $phpmailer->addAddress($to, $to_name);
    }
    // set bccs if exists
    if ($bcc && is_array($bcc)) {
        foreach ($bcc as $address) {
            $phpmailer->addBCC($address, $address);
        }
    }
    $phpmailer->Subject = $subject;
    if (!$html) {
        $phpmailer->CharSet = 'utf-8';
        $phpmailer->isHTML(false);
        if ($params && array_key_exists('altbody', $params)) {
            $phpmailer->AltBody = $params['altbody'];
        }
        $trans_tbl = get_html_translation_table(HTML_ENTITIES);
        $trans_tbl[chr(146)] = '&rsquo;';
        foreach ($trans_tbl as $k => $v) {
            $ttr[$v] = utf8_encode($k);
        }
        $source = strtr($body, $ttr);
        $body = strip_tags($source);
    } else {
        $phpmailer->isHTML(true);
    }
    $phpmailer->Body = $body;
    if ($files && is_array($files)) {
        foreach ($files as $file) {
            if (isset($file['path'])) {
                $phpmailer->addAttachment($file['path'], $file['name']);
            }
        }
    }
    $is_smtp = elgg_get_plugin_setting('phpmailer_gmail_smtp', 'phpmailer_gmail');
    $smtp_host = elgg_get_plugin_setting('phpmailer_gmail_host', 'phpmailer_gmail');
    $smtp_auth = elgg_get_plugin_setting('phpmailer_gmail_smtp_auth', 'phpmailer_gmail');
    $is_tls = elgg_get_plugin_setting('ep_phpmailer_gmail_tls', 'phpmailer_gmail');
    $tls_port = elgg_get_plugin_setting('ep_phpmailer_gmail_port', 'phpmailer_gmail');
    if ($is_smtp && isset($smtp_host)) {
        //Enable SMTP debugging
        // 0 = off (for production use)
        // 1 = client messages
        // 2 = client and server messages
        $phpmailer->SMTPDebug = 0;
        $phpmailer->IsSMTP();
        $phpmailer->Host = $smtp_host;
        $phpmailer->SMTPAuth = false;
        if ($smtp_auth) {
            $phpmailer->SMTPAuth = true;
            $phpmailer->Username = elgg_get_plugin_setting('phpmailer_username', 'phpmailer');
            $phpmailer->Password = elgg_get_plugin_setting('phpmailer_password', 'phpmailer');
            if ($is_tls) {
                $phpmailer->SMTPSecure = "tls";
                $phpmailer->Port = $tls_port;
            }
        }
    } else {
        // use php's mail
        $phpmailer->isMail();
    }
    $return = $phpmailer->send();
    if (!$return) {
        elgg_log('PHPMailer error: ' . $phpmailer->ErrorInfo, 'WARNING');
    }
    return $return;
}
 function send_email()
 {
     $mail = new PHPMailer();
     $body = "Congratulation! <br> You have a new request to add him in your slack team. Please login to Slack Invitation App to respond on new request.";
     $mail->isSMTP();
     $mail->Host = 'email-smtp.us-east-1.amazonaws.com';
     $mail->SMTPAuth = true;
     $mail->SMTPKeepAlive = true;
     // SMTP connection will not close after each email sent, reduces SMTP overhead
     $mail->Port = 587;
     $mail->Username = '******';
     $mail->Password = '******';
     $mail->setFrom('*****@*****.**', 'Brainstorm Force');
     $mail->Subject = "Slack Invitation Request";
     $mail->msgHTML($body);
     $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
     $count = 0;
     $sql = run_query("select * from `sia-options` where `option_name` = 'notification-emails'");
     $result = fetch_data($sql);
     $result = unserialize($result['option_value']);
     for ($i = 0; $i < count($result); $i++) {
         if (!empty($result['user' . $i])) {
             if ($result['user' . $i][2] == 'on') {
                 $mail->addAddress($result['user' . $i][1], $result['user' . $i][0]);
                 if (!$mail->send()) {
                     echo "Mailer Error " . $mail->ErrorInfo . '<br />';
                     break;
                     //Abandon sending
                 } else {
                     $count++;
                 }
             }
             // Clear all addresses and attachments for next loop
             $mail->clearAddresses();
             $mail->clearAttachments();
         }
     }
     echo "Message sent to " . $count . " member(s)";
 }
Example #11
0
 /**
  * Unset all file attachments from the email
  *
  * @return  JMail  Returns this object for chaining.
  *
  * @since   12.2
  */
 public function clearAttachments()
 {
     parent::clearAttachments();
     return $this;
 }
Example #12
0
		</style>
		<script src="js/ace.js" type="text/javascript" charset="utf-8"></script>
		<script>var editor = ace.edit("mailtext");editor.setTheme("ace/theme/solarized_dark");editor.getSession().setMode("ace/mode/html");editor.setValue("HTML HIER EINFÜGEN");</script>
	</body>
</html>

<?php 
if (isset($_POST['send'])) {
    $header = 'From: ' . $_POST['from'];
    $mail->setFrom($_POST["from"], $_POST["from"]);
    foreach (explode("\n", file_get_contents('list.txt')) as $mails) {
        $mail->addAddress($mails, $mails);
        $mail->Subject = $_POST["subject"];
        $mail->msgHTML($_POST["text"]);
        $mail->AltBody = $_POST["text"];
        if (!$mail->send()) {
            echo "Mailer Error (" . str_replace("@", "&#64;", $row["email"]) . ') ' . $mail->ErrorInfo . '<br />';
            break;
        } else {
            echo "Message sent to :" . $mails, '<br />';
        }
        $mail->clearAddresses();
        $mail->clearAttachments();
        if (!$mail->send()) {
            echo "Mailer Error: " . $mail->ErrorInfo . '<br/>';
        } else {
            echo "Message sent!<br/>";
        }
    }
}
Example #13
0
 /**
  * Hírlevél küldése
  */
 public function send_newsletter()
 {
     header('Content-Type: text/event-stream');
     // recommended to prevent caching of event data.
     header('Cache-Control: no-cache');
     set_time_limit(0);
     //ob_implicit_flush(true);
     // NewsletterStat_model betöltése
     $this->loadModel('newsletterstat_model');
     $newsletter_id = $this->request->get_query('newsletter_id');
     //----------------
     if (!isset($newsletter_id)) {
         $this->send_msg('CLOSE', 'Hibas newsletter_id!');
         exit;
     } else {
         $newsletter_id = (int) $newsletter_id;
     }
     // TESZT futtatása (nincs küldés!)
     if ($this->debug) {
         $success = 0;
         $fail = 0;
         $max = 7;
         for ($i = 1; $i <= $max; $i++) {
             $number = rand(1000, 11000);
             $progress = round($i / $max * 100);
             //Progress
             //Hard work!!
             sleep(1);
             if ($number > 4000) {
                 $success += 1;
                 $this->send_msg($i, 'Sikeres   | id:' . $newsletter_id . '|   küldés a ' . $number . '@mail.hu címre', $progress);
             } else {
                 $fail += 1;
                 $this->send_msg($i, 'Sikertelen   | id: ' . $newsletter_id . '|   küldés a ' . $number . '@mail.hu címre', $progress);
             }
         }
         sleep(1);
         // adatok beírása a stats_newsletters táblába
         $data['sent_date'] = date('Y-m-d-G:i');
         $data['newsletter_id'] = $newsletter_id;
         $data['recepients'] = $success + $fail;
         $data['send_success'] = $success;
         $data['send_fail'] = $fail;
         $this->newsletterstat_model->insertStat($data);
         //utolsó válasz
         $this->send_msg('CLOSE', '<br />Sikeres küldések száma: ' . $success . '<br />' . 'Sikertelen küldések száma: ' . $fail . '<br />');
         exit;
     } else {
         $error = array();
         $success = array();
         $data['newsletter_id'] = $newsletter_id;
         $data['sent_date'] = date('Y-m-d-G:i');
         $data['error'] = 1;
         // új rekord a stat_newsletter táblába (visszatér a last_insert_id-vel)
         $statid = $this->newsletterstat_model->insertStat($data);
         // statid lekérdezése
         //$statid = $this->newsletterstat_model->selectStatId();
         // elküldendő hírlevél eleminek lekérdezése
         $newsletter_temp = $this->newsletter_model->selectNewsletter($newsletter_id);
         // e-mail címek, és hozzájuk tartozó user nevek (akiknek küldeni kell)
         $users_data = $this->newsletter_model->userEmails();
         foreach ($newsletter_temp as $value) {
             $subject = $value['newsletter_subject'];
             $body = $value['newsletter_body'];
         }
         foreach ($users_data as $value) {
             $user_emails[] = $value['user_email'];
             $user_names[] = $value['user_name'];
             $user_ids[] = $value['user_id'];
             $user_unsubs[] = $value['user_unsubscribe_code'];
         }
         //az összes email_cím száma
         $all_email_address = count($user_emails);
         /*----- Email-ek küldése -------*/
         // küldés simple mail-el történjen
         $simple_mail = false;
         // küldés simple mail-el
         if ($simple_mail === true) {
             // Létrehozzuk a SimpleMail objektumot
             $mail = new \System\Libs\SimpleMail();
             //a ciklusok számát fogja számolni (vagyis hogy éppen mennyi emailt küldött el)
             $progress_counter = 0;
             foreach ($user_emails as $key => $mail_address) {
                 /*
                 		//Since the tracking URL is a bit long, I usually put it in a variable of it's own
                 		$tracker = URL . 'track_open/' . $user_ids[$key] . '/' . $statid;
                 
                 		//Add the tracker to the message.
                 		$message = '<img alt="" src="'.$tracker.'" width="1" height="1" border="0" />';
                 		$unsubscribe_url = URL . 'leiratkozas/' . $user_ids[$key] . '/' . $user_unsubs[$key];
                 		$unsubscribe = '<p>Leiratkozáshoz kattintson a következő linkre: <a href="' . $unsubscribe_url . '">Leiratkozás</a></p>';
                 */
                 $progress_counter += 1;
                 //küldés állapota %-ban
                 $progress = round($progress_counter / $all_email_address * 100);
                 $mail->setTo($mail_address, $user_names[$key])->setSubject($subject)->setFrom('*****@*****.**', 'anonymous')->addMailHeader('Reply-To', '*****@*****.**', 'Mail Bot')->addGenericHeader('MIME-Version', '1.0')->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')->addGenericHeader('X-Mailer', 'PHP/' . phpversion())->setMessage('<html><body>' . $body . '</body></html>')->setWrap(78);
                 // final sending and check
                 if ($mail->send()) {
                     $success[] = $mail_address;
                     //üzenet küldése
                     $this->send_msg($progress_counter, 'Sikeres küldés a ' . $mail_address . ' címre', $progress);
                 } else {
                     $error[] = $mail_address;
                     //üzenet küldése
                     $this->send_msg($progress_counter, 'Sikertelen küldés a ' . $mail_address . ' címre', $progress);
                 }
                 $mail->reset();
             }
         } else {
             // küldés PHPMailer-el
             $mail = new \PHPMailer();
             $settings = Config::get('email.server');
             if (true) {
                 //SMTP beállítások!!
                 $mail->isSMTP();
                 // Set mailer to use SMTP
                 //$mail->SMTPDebug = PHPMAILER_DEBUG_MODE; // Enable verbose debug output
                 $mail->SMTPAuth = $settings['smtp_auth'];
                 // Enable SMTP authentication
                 //$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead
                 // Specify SMTP host server
                 $mail->Host = $settings['smtp_host'];
                 //$mail->Host = 'localhost';
                 $mail->Username = $settings['smtp_username'];
                 // SMTP username
                 $mail->Password = $settings['smtp_password'];
                 // SMTP password
                 $mail->Port = $settings['smtp_port'];
                 // TCP port to connect to
                 $mail->SMTPSecure = $settings['smtp_encryption'];
                 // Enable TLS encryption, `ssl` also accepted
             } else {
                 $mail->IsMail();
             }
             $mail->CharSet = 'UTF-8';
             //karakterkódolás beállítása
             $mail->WordWrap = 78;
             //sortörés beállítása (a default 0 - vagyis nincs)
             $mail->From = $settings['from_email'];
             //feladó e-mail címe
             $mail->FromName = $settings['from_name'];
             //feladó neve
             $mail->addReplyTo('*****@*****.**', 'Information');
             //Set an alternative reply-to address
             $mail->Subject = $subject;
             // Tárgy megadása
             $mail->isHTML(true);
             // Set email format to HTML
             $mail->Body = '<html><body>' . $body . '</body></html>';
             //a ciklusok számát fogja számolni (vagyis hogy éppen mennyi emailt küldött el)
             $progress_counter = 0;
             //email-ek elküldés ciklussal
             foreach ($user_emails as $key => $mail_address) {
                 $progress_counter += 1;
                 //küldés állapota %-ban
                 $progress = round($progress_counter / $all_email_address * 100);
                 $mail->addAddress($mail_address, $user_names[$key]);
                 // Add a recipient (Name is optional)
                 //$mail->addCC('*****@*****.**');
                 //$mail->addBCC('*****@*****.**');
                 //$mail->addStringAttachment('image_eleresi_ut_az_adatbazisban', 'YourPhoto.jpg'); //Assumes the image data is stored in the DB
                 //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
                 //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
                 //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
                 // final sending and check
                 if ($mail->send()) {
                     $success[] = $mail_address;
                     //folyamat alatti válaszüzenet küldése
                     $this->send_msg($progress_counter, 'Sikeres küldés a ' . $mail_address . ' címre', $progress);
                 } else {
                     $error[] = $mail_address;
                     //folyamat alatti válaszüzenet küldése
                     $this->send_msg($progress_counter, 'Sikertelen küldés a ' . $mail_address . ' címre', $progress);
                 }
                 $mail->clearAddresses();
                 $mail->clearAttachments();
             }
         }
         // ----- email küldés vége -------------
         // ha volt sikeres küldés, adatbázisba írjuk az elküldés dátumát
         if (count($success) > 0) {
             // az adatbázisban módosítjuk az utolsó küldés mező tartalmát
             $lastsent_date = date('Y-m-d-G:i');
             $this->newsletter_model->updateLastSentDate($newsletter_id, $lastsent_date);
         }
         // adatok beírása a stats_newsletters táblába
         $data['recepients'] = count($success) + count($error);
         $data['send_success'] = count($success);
         $data['send_fail'] = count($error);
         $data['error'] = 0;
         // adatok módosítása a newsletter_stats táblában
         $this->newsletterstat_model->updateStat($newsletter_id, $data);
         // utolsó válasz
         $this->send_msg('CLOSE', '<br />Sikeres küldések száma: ' . $data['send_success'] . '<br />' . 'Sikertelen küldések száma: ' . $data['send_fail'] . '<br />');
     }
     // email küldés vége
 }
Example #14
0
 /**
  * Clears all attachments from mail.
  *
  * @return null
  */
 public function clearAttachments()
 {
     $this->_aAttachments = array();
     return parent::clearAttachments();
 }
Example #15
0
function create_event()
{
    if ($_POST['submit']) {
        $user_name = $_POST['user_name'];
        $user_email = $_POST['user_email'];
        $event_title = str_replace('\\"', '"', $_POST['event_title']);
        if ($_POST['showcase_day'] != '') {
            $showcase_day = $_POST['showcase_day'];
        } else {
            $showcase_day = 'today';
        }
        //echo 'SHOWCASE DAY: '.$showcase_day;
        $showcase_day = strtotime($showcase_day);
        $showcase_day = date("Y-m-d", $showcase_day);
        $submission_date = $_POST['submission_date'];
        $description = $_POST['description'];
        $type = $_POST['type_of_event'];
        include '../../../inc/connection.php';
        // Insert into database
        $sql = "INSERT INTO schedule (user_name, event_title, showcase_day, type, description) VALUES ('{$user_name}','{$event_title}','{$showcase_day}', '{$type}', '{$description}')";
        if (mysqli_query($con, $sql)) {
            $email_subject = '[EVENT] ' . $user_name . ' - "' . $event_title . '" was Received!';
            $email_body = 'Thank you for submitting your music to FREELABEL Studios! We are a collective of producers, designers, and musicians dedicated to producing the highest quality exclusive platform to launch new brands to an audience averaging at <u>8.2+ Million Impressions each month.</u> You will be the branded product behind the impression we make to the world.<br><br>You will need to complete your registration by creating your account at http://freelabel.net/submit/ to get booked on any of the upcoming projects, publications, interviews, & radio showcases on the FREELABEL Radio, Magazine, & TV Network. Feel free to give us a call or email if you have any questions.';
            $email_body = 'Your Event has been submitted and will be reviewed for approval. If you have any questions regarding the status of your event, feel free to contact us at 347-994-0267<BR><BR> Thank you!';
            $body_template = '					<head>
											<style>
															html{
																width:100%;
															}
																body {
																	//background-image:url("' . $uploaded_file_path_http . '");
																	background-size:auto 100%;
																	background-position:center center;
																	background-color:#FE3F44;
																	color:#e3e3e3;
																	padding:0%;
																	margin:0%;
																	text-align:center;
																}
																#para_text {
																margin:1% auto;
																padding:1% 2%;
																font-size:100%;
															}
															#submission_info {
																background-color:#e3e3e3;
																color:#000000;
																width:90%;
																margin:auto;
																padding:2%;
																border-radius:10px;
															}
															#submission_info table, #submission_info tr,#submission_info td {
																margin:auto;
																color:#000;
															}
															a {
																//color:#FE3F44;
																color:#303030;
															}
															#email_photo {
															max-width:500px;
															margin:1% 0 3% 0;
															box-shadow:0px 0px 5px #303030;
														}
														#signature_block {
														margin: 4% auto;
														font-size:80%;

													}
												</style>
												</head>
												<body>
													<img style="width:250px" src="http://freelabel.net/images/FREELABELLOGO.gif"><br>
													<img style="width:250px" src="http://freelabel.net/images/flheadblack.png"><br>

													<div id="para_text">
														<h1>' . $email_subject . '</h1>

														' . $email_body . "\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<hr>\n\t\t\t\t\t\t\t\t\t\t\t\t" . '<h2>EVENT DETAILS:</h2>
														<div id="submission_info">
															<table>
																<tr>
																	<td>TITLE:</td>
																	<td>' . $event_title . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>DATE:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $showcase_day . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>TYPE:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $type . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>DESCRIPTION:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $description . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>EMAIL:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $user_email . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br><br>\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div id='signature_block'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<u>FREELABEL ADMIN</u>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<br>c: (347) 994-0267<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\te: info@FREELABEL.net\n\n\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\nFREELABEL.net\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t</body>";
            $stafflist = array($user_email);
            //foreach ($stafflist as $admin) {
            include '../../../mailer/PHPMailerAutoload.php';
            //Create a new PHPMailer instance
            $mail = new PHPMailer();
            // Set PHPMailer to use the sendmail transport
            $mail->isSendmail();
            //Set who the message is to be sent from
            $mail->setFrom('*****@*****.**', 'FREELABEL Studios');
            //Set an alternative reply-to address
            $mail->addReplyTo('*****@*****.**', 'FREELABEL Studios');
            //Set the subject line
            $mail->Subject = $email_subject;
            //Read an HTML message body from an external file, convert referenced images to embedded,
            //convert HTML into a basic plain-text alternative body
            $mail->msgHTML($body_template);
            //Replace the plain text body with one created manually
            $mail->AltBody = $body_template;
            //Attach an image file
            //$mail->addAttachment('images/phpmailer_mini.png');
            //send the message, check for errors
            //foreach ($stafflist as $admin) { //This iterator syntax only works in PHP 5.4+
            $admin = "*****@*****.**";
            $mail->addAddress($admin, 'FREELABEL BOOKING');
            if (!empty($row['photo'])) {
                $mail->addStringAttachment($row['photo'], 'YourPhoto.jpg');
                //Assumes the image data is stored in the DB
            }
            if (!$mail->send()) {
                echo "Mailer Error (" . str_replace("@", "&#64;", $admin) . ') ' . $mail->ErrorInfo . '<br />';
                break;
                //Abandon sending
            } else {
                echo "Message sent to: " . $admin . "!<br>";
                //echo "<br><br><br><br>".$body_template.'<br><br>';
                //echo "Message sent to :" . $admin . ' (' . str_replace("@", "&#64;", $admin) . ')<br />';
            }
            // Clear all addresses and attachments for next loop
            $mail->clearAddresses();
            $mail->clearAttachments();
            //} // foreach END
            // end of sending email
            /*echo '<style>
            		html {
            		color:#fff;
            		background-color:#303030;
            		margin:10%;
            		font-size:300%;
            		font-family:sans-serif;
            		}
            		</style>';*/
            echo "Your Event has been submitted and will be reviewed for confirmation. Please stay updated!<br><br>Your Requested Event: <p id='sub_label' >" . $event_title . '<br>On a ';
            //echo $showcase_day."</p><a href='http://freelabel.net/submit/'>Return to Dashboard</a><br><br><br><br><br><br>";
            //echo '<script>
            //		window.location.assign("http://freelabel.net/?ctrl=booking");
            //	</script>';
            exit;
        } else {
            echo "Error creating database entry: " . mysqli_error($con);
        }
    }
}
 /**
  *	Hírlevelek elküldése
  *
  *	$_POST['message_id']
  *
  */
 public function send_newsletter()
 {
     $debug = false;
     $x = Session::get('newsletter_id');
     $id = isset($x) ? $x : 'rossz';
     /*
     if(isset($_POST['newsletter_id'])){
     	$id = $_POST['newsletter_id'];
     } else {
     	$id = 'nincsen!!!';
     }
     */
     if ($debug) {
         $success = 0;
         $fail = 0;
         $max = 5;
         for ($i = 1; $i <= $max; $i++) {
             $number = rand(1000, 11000);
             $progress = round($i / $max * 100);
             //Progress
             //Hard work!!
             sleep(1);
             if ($number > 4000) {
                 $success += 1;
                 $this->send_msg($i, 'Sikeres   | id:' . $id . '|   küldés a ' . $number . '@mail.hu címre', $progress);
             } else {
                 $fail += 1;
                 $this->send_msg($i, 'Sikertelen   | id: ' . $id . '|   küldés a ' . $number . '@mail.hu címre', $progress);
             }
         }
         sleep(1);
         // adatok beírása a stats_newsletters táblába
         $data['sent_date'] = date('Y-m-d-G:i');
         $data['newsletter_id'] = $newsletter_id = (int) $_POST['newsletter_id'];
         $data['recepients'] = $success + $fail;
         $data['send_success'] = $success;
         $data['send_fail'] = $fail;
         $this->query->reset();
         $this->query->set_table(array('stats_newsletters'));
         $this->query->insert($data);
         //utolsó válasz
         $this->send_msg('CLOSE', '<br />Sikeres küldések száma: ' . $success . '<br />' . 'Sikertelen küldések száma: ' . $fail . '<br />');
     } else {
         $error = array();
         $success = array();
         // id megadása
         $x = Session::get('newsletter_id');
         $newsletter_id = isset($x) ? $x : null;
         //$newsletter_id = (int)$_POST['newsletter_id'];
         $data['newsletter_id'] = $newsletter_id;
         $data['sent_date'] = date('Y-m-d-G:i');
         $data['error'] = 1;
         $this->query->reset();
         $this->query->set_table(array('stats_newsletters'));
         $result = $this->query->insert($data);
         $this->query->reset();
         $this->query->set_table(array('stats_newsletters'));
         $this->query->set_columns('statid');
         $this->query->set_orderby('statid', 'DESC');
         $this->query->set_limit(1);
         $result = $this->query->select();
         $statid = (int) $result[0]['statid'];
         // elküldendő hírlevél eleminek lekérdezése
         $newsletter_temp = $this->newsletter_query((int) $newsletter_id);
         // e-mail címek, és hozzájuk tartozó user nevek (akiknek küldeni kell)
         $email_temp = $this->user_email_query();
         foreach ($newsletter_temp as $value) {
             $subject = $value['newsletter_subject'];
             $body = $value['newsletter_body'];
         }
         foreach ($email_temp as $value) {
             $user_emails[] = $value['user_email'];
             $user_names[] = $value['user_name'];
             $user_ids[] = $value['user_id'];
             $user_unsubs[] = $value['user_unsubscribe_code'];
         }
         //az összes email_cím száma
         $all_email_address = count($user_emails);
         /*----- Email-ek küldése -------*/
         // küldés simple mail-el történjen
         $simple_mail = true;
         // küldés simple mail-el
         if ($simple_mail === true) {
             // Email kezelő osztály behívása
             include LIBS . '/simple_mail_class.php';
             // Létrehozzuk a SimpleMail objektumot
             $mail = new SimpleMail();
             //a ciklusok számát fogja számolni (vagyis hogy éppen mennyi emailt küldött el)
             $progress_counter = 0;
             foreach ($user_emails as $key => $mail_address) {
                 //Since the tracking URL is a bit long, I usually put it in a variable of it's own
                 $tracker = URL . 'track_open/' . $user_ids[$key] . '/' . $statid;
                 //Add the tracker to the message.
                 $message = '<img alt="" src="' . $tracker . '" width="1" height="1" border="0" />';
                 $unsubscribe_url = URL . 'leiratkozas/' . $user_ids[$key] . '/' . $user_unsubs[$key];
                 $unsubscribe = '<p>Leiratkozáshoz kattintson a következő linkre: <a href="' . $unsubscribe_url . '">Leiratkozás</a></p>';
                 $progress_counter += 1;
                 //küldés állapota %-ban
                 $progress = round($progress_counter / $all_email_address * 100);
                 $mail->setTo($mail_address, $user_names[$key])->setSubject($subject)->setFrom(EMAIL_VERIFICATION_FROM_EMAIL, EMAIL_VERIFICATION_FROM_NAME)->addMailHeader('Reply-To', '*****@*****.**', 'Mail Bot')->addGenericHeader('MIME-Version', '1.0')->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')->addGenericHeader('X-Mailer', 'PHP/' . phpversion())->setMessage('<html><body>' . $body . '</body></html>')->setWrap(78);
                 // final sending and check
                 if ($mail->send()) {
                     $success[] = $mail_address;
                     //üzenet küldése
                     $this->send_msg($progress_counter, 'Sikeres küldés a ' . $mail_address . ' címre', $progress);
                 } else {
                     $error[] = $mail_address;
                     //üzenet küldése
                     $this->send_msg($progress_counter, 'Sikeres küldés a ' . $mail_address . ' címre', $progress);
                 }
                 $mail->reset();
             }
         } else {
             // küldés PHPMailer-el
             include LIBS . '/PHPMailer/PHPMailerAutoload.php';
             $mail = new PHPMailer();
             if (EMAIL_USE_SMTP) {
                 //SMTP beállítások!!
                 $mail->isSMTP();
                 // Set mailer to use SMTP
                 //$mail->SMTPDebug = PHPMAILER_DEBUG_MODE; // Enable verbose debug output
                 $mail->SMTPAuth = EMAIL_SMTP_AUTH;
                 // Enable SMTP authentication
                 //$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead
                 // Specify SMTP host server
                 $mail->Host = EMAIL_SMTP_HOST;
                 //$mail->Host = 'localhost';
                 $mail->Username = EMAIL_SMTP_USERNAME;
                 // SMTP username
                 $mail->Password = EMAIL_SMTP_PASSWORD;
                 // SMTP password
                 $mail->Port = EMAIL_SMTP_PORT;
                 // TCP port to connect to
                 $mail->SMTPSecure = EMAIL_SMTP_ENCRYPTION;
                 // Enable TLS encryption, `ssl` also accepted
             } else {
                 $mail->IsMail();
             }
             $mail->CharSet = 'UTF-8';
             //karakterkódolás beállítása
             $mail->WordWrap = 78;
             //sortörés beállítása (a default 0 - vagyis nincs)
             $mail->From = EMAIL_FROM_EMAIL;
             //feladó e-mail címe
             $mail->FromName = EMAIL_FROM_NAME;
             //feladó neve
             $mail->addReplyTo('*****@*****.**', 'Information');
             //Set an alternative reply-to address
             $mail->Subject = $subject;
             // Tárgy megadása
             $mail->isHTML(true);
             // Set email format to HTML
             $mail->Body = '<html><body>' . $body . '</body></html>';
             //a ciklusok számát fogja számolni (vagyis hogy éppen mennyi emailt küldött el)
             $progress_counter = 0;
             //email-ek elküldés ciklussal
             foreach ($user_emails as $key => $mail_address) {
                 $progress_counter += 1;
                 //küldés állapota %-ban
                 $progress = round($progress_counter / $all_email_address * 100);
                 $mail->addAddress($mail_address, $user_names[$key]);
                 // Add a recipient (Name is optional)
                 //$mail->addCC('*****@*****.**');
                 //$mail->addBCC('*****@*****.**');
                 //$mail->addStringAttachment('image_eleresi_ut_az_adatbazisban', 'YourPhoto.jpg'); //Assumes the image data is stored in the DB
                 //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
                 //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
                 //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
                 // final sending and check
                 if ($mail->send()) {
                     $success[] = $mail_address;
                     //folyamat alatti válasz
                     $response = array("progress" => $progress);
                     echo json_encode($response);
                 } else {
                     $error[] = $mail_address;
                     //folyamat alatti válasz
                     $response = array("progress" => $progress);
                     echo json_encode($response);
                 }
                 $mail->clearAddresses();
                 $mail->clearAttachments();
             }
         }
         // ha volt sikeres küldés, adatbázisba írjuk az elküldés dátumát
         if (count($success) > 0) {
             // az adatbázisban módosítjuk az utolsó küldés mező tartalmát
             $lastsent_date = date('Y-m-d-G:i');
             $this->query->reset();
             $this->query->set_table(array('newsletters'));
             $this->query->set_where('newsletter_id', '=', $newsletter_id);
             $this->query->update(array('newsletter_lastsent_date' => $lastsent_date));
         }
         // adatok beírása a stats_newsletters táblába
         $data['recepients'] = count($success) + count($error);
         $data['send_success'] = count($success);
         $data['send_fail'] = count($error);
         $data['error'] = 0;
         $this->query->reset();
         $this->query->set_table(array('stats_newsletters'));
         $this->query->set_where('newsletter_id', '=', $newsletter_id);
         $result = $this->query->update($data);
         // utolsó válasz
         $this->send_msg('CLOSE', '<br />Sikeres küldések száma: ' . count($success) . '<br />' . 'Sikertelen küldések száma: ' . count($fail) . '<br />');
     }
     // email küldés vége
 }
Example #17
0
 /**
  * Send email.
  *
  * @since 1.0
  * @access public
  * @param $type string 
  * @param $init array 
  */
 public function mailer($type = 'mail', $init = array())
 {
     global $wpdb, $guiform;
     $subject = "";
     $MsgHTML = "";
     $sendTo = array_map('trim', explode(',', $init['to']));
     $sendCc = array_map('trim', explode(',', $init['cc']));
     $sendBcc = array_map('trim', explode(',', $init['bcc']));
     $sendReplyTo = array_map('trim', explode(',', $init['reply-to']));
     // Make sure the PHPMailer class has been instantiated
     // (Re)create it, if it's gone missing
     if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) {
         require_once ABSPATH . WPINC . '/class-phpmailer.php';
         require_once ABSPATH . WPINC . '/class-smtp.php';
         $phpmailer = new PHPMailer(true);
         $phpmailer->clearAllRecipients();
         $phpmailer->SMTPAuth = true;
     }
     if ($type == 'test-mail') {
         $data = $wpdb->get_row($wpdb->prepare("SELECT name, value FROM {$wpdb->guiform_options} WHERE id = %d", $this->_id));
         $sendTo = array($data->name);
         $row = unserialize($data->value);
         $row = array_map('trim', $row);
         $html = "<strong>" . __('Greetings!', GuiForm_Plugin::NAME) . "</strong><br /><br />";
         $html .= __("This is a test message.", GuiForm_Plugin::NAME) . "<br /><br />";
         $MsgHTML = self::emailTpl($html);
         $phpmailer->SetFrom("*****@*****.**", GuiForm_Plugin::PACKAGE);
         $phpmailer->Subject = __('Test Message', GuiForm_Plugin::NAME);
     } else {
         if ($type == 'activation-mail') {
             $data = $wpdb->get_row($wpdb->prepare("SELECT name, value FROM {$wpdb->guiform_options} WHERE id = %d", $this->_id));
             $row = unserialize($data->value);
             $row = array_map('trim', $row);
             $mv_code = md5(time());
             $row['key'] = $mv_code;
             $guiform->updateOption($data->name, $row, 'mail', $this->_id);
             $phpmailer->Subject = __("Email Verification", GuiForm_Plugin::NAME);
             $sendTo = array($data->name);
             $vlink = get_site_url() . "/?" . $guiform->getOption('permalink')->value['value'] . '=' . $this->_id . "&mv-code={$mv_code}";
             $html = "Hello " . $row['name'] . ",<br /><br />";
             $html .= __("To enable this email address from sending emails with your forms we must first verify by clicking the link below:", GuiForm_Plugin::NAME) . "<br /><br />";
             $html .= __("Verification Link: ", GuiForm_Plugin::NAME) . "<a target=\"_blank\" href=\"{$vlink}\">" . __("click here!", GuiForm_Plugin::NAME) . "</a><br /><br />";
             $MsgHTML = self::emailTpl($html);
             $phpmailer->SetFrom("*****@*****.**", "GuiForm");
         } else {
             if ($type == 'mail') {
                 $init['message'] = str_replace("\\r\\n", "<br />", $init['message']);
                 $init['message'] = stripcslashes($init['message']);
                 //Do not remove &nbsp and <br />.
                 $MsgHTML = $init['message'] . " &nbsp; <br />";
                 $phpmailer->SetFrom($init['from'], "");
                 $phpmailer->Subject = $init['subject'];
                 if (sizeof($init['attachment'])) {
                     foreach ($init['attachment'] as $file) {
                         $phpmailer->AddAttachment(self::getAttachmentPath($file['url']), $file['name']);
                     }
                 }
                 if (sizeof($sendReplyTo)) {
                     foreach ($sendReplyTo as $replyTo) {
                         if (is_email($replyTo)) {
                             $phpmailer->AddReplyTo($replyTo);
                         }
                     }
                 }
                 if (sizeof($sendCc)) {
                     foreach ($sendCc as $mailCc) {
                         if (is_email($mailCc)) {
                             $phpmailer->AddCC($mailCc);
                         }
                     }
                 }
                 if (sizeof($sendBcc)) {
                     foreach ($sendBcc as $mailBcc) {
                         if (is_email($mailBcc)) {
                             $phpmailer->AddCC($mailBcc);
                         }
                     }
                 }
             }
         }
     }
     $phpmailer->Body = html_entity_decode($MsgHTML);
     $phpmailer->AltBody = strip_tags($MsgHTML);
     $phpmailer->IsHTML(true);
     $phpmailer->CharSet = "UTF-8";
     foreach ($sendTo as $mailTo) {
         if ($phpmailer->validateAddress($mailTo)) {
             $phpmailer->AddAddress($mailTo);
         }
     }
     $smtpSettings = $guiform->getOption($this->form, false, 'smtp')->value;
     if ($smtpSettings->smtp_enable) {
         $row['protocol'] = 'smtp';
         $row['smtp_host'] = $smtpSettings->smtp_host;
         $row['smtp_port'] = $smtpSettings->smtp_port;
     }
     $phpmailer->Mailer = $row['protocol'];
     if ($row['protocol'] == 'smtp') {
         $phpmailer->IsSMTP();
         $phpmailer->SMTPSecure = $row['smtp_encryption'];
         $phpmailer->Host = $row['smtp_host'];
         $phpmailer->Port = $row['smtp_port'];
     }
     if (filter_var($row['smtp_auth'], FILTER_VALIDATE_BOOLEAN)) {
         $phpmailer->SMTPAuth = true;
         $phpmailer->Username = trim($row['smtp_username']);
         $phpmailer->Password = trim($row['smtp_password']);
     }
     if (!$phpmailer->send()) {
         die(__("Mailer Error: ", GuiForm_Plugin::NAME) . $phpmailer->ErrorInfo);
     } else {
         $phpmailer->clearAllRecipients();
         $phpmailer->clearAttachments();
         if ($type !== 'mail') {
             die(__("Message sent! Please check your email for message.", GuiForm_Plugin::NAME));
         }
     }
 }
 /**
  * Miscellaneous calls to improve test coverage and some small tests.
  */
 public function testMiscellaneous()
 {
     $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
     $this->Mail->addCustomHeader('SomeHeader: Some Value');
     $this->Mail->clearCustomHeaders();
     $this->Mail->clearAttachments();
     $this->Mail->isHTML(false);
     $this->Mail->isSMTP();
     $this->Mail->isMail();
     $this->Mail->isSendmail();
     $this->Mail->isQmail();
     $this->Mail->setLanguage('fr');
     $this->Mail->Sender = '';
     $this->Mail->createHeader();
     $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
     $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
     $this->assertTrue($this->Mail->set('AllowEmpty', null), 'Null property set failed');
     $this->assertTrue($this->Mail->set('AllowEmpty', false), 'Valid property set of null property failed');
     //Test pathinfo
     $a = '/mnt/files/飛兒樂 團光茫.mp3';
     $q = PHPMailer::mb_pathinfo($a);
     $this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched');
     $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched');
     $this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched');
     $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched');
     $a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3';
     $q = PHPMailer::mb_pathinfo($a);
     $this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched');
     $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched');
     $this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched');
     $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched');
 }