clearAddresses() public method

Clear all To recipients.
public clearAddresses ( ) : void
return void
Example #1
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 #2
0
 public static function order($name, $email = '', $phone = '', $address = '', $comment = '', $adminNotifyTplID = 'admin_purchase_notify', $customerNotifyTplID = 'user_purchase_notify')
 {
     global $db;
     $user = \cf\User::getLoggedIn();
     $productList = '';
     $products = \cf\api\cart\getList();
     if (!array_key_exists('contents', $products) || !count($products['contents'])) {
         return false;
     }
     $tpl = new MailTemplate('order');
     execQuery("\n\t\t\tINSERT INTO cf_orders (created,customer_name, customer_email, customer_phone, customer_address, customer_comments, comments)\n\t\t\tVALUES(NOW(),:name, :email, :phone, :address, :comments, :contents)", array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comments' => $comment, 'contents' => $tpl->parseBody(array('cart' => $products))));
     $orderId = $db->lastInsertId();
     $msgParams = array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comment' => $comment, 'order' => $orderId, 'total' => $products['total'], 'products' => $products['contents']);
     \cf\api\cart\clear();
     $mail = new \PHPMailer();
     $mail->CharSet = 'UTF-8';
     if ($adminNotifyTplID) {
         $tpl = new MailTemplate($adminNotifyTplID);
         $mail->Subject = $tpl->parseSubject($msgParams);
         $mail->MsgHTML($tpl->parseBody($msgParams));
         foreach ($tpl->recipients() as $address) {
             $mail->addAddress($address);
         }
         $mail->Send();
     }
     $mail->clearAddresses();
     if ($customerNotifyTplID && $email) {
         $tpl = new MailTemplate($customerNotifyTplID);
         $mail->Subject = $tpl->parseSubject($msgParams);
         $mail->MsgHTML($tpl->parseBody($msgParams));
         $mail->addAddress($email);
         $mail->Send();
     }
     return $orderId;
 }
 public function actionAdd()
 {
     if (!isset($_POST['NewsHeader']) || !isset($_POST['NewsPreview']) || !isset($_POST['NewsText']) || !isset($_POST['NewsTags'])) {
         header("HTTP/1.0 404 Not Found");
         throw new E404Exception('Required params can not be null');
     }
     $NewsRecord = new News();
     $NewsRecord->NewsHeader = $_POST['NewsHeader'];
     $NewsRecord->NewsPreview = $_POST['NewsPreview'];
     $NewsRecord->NewsText = $_POST['NewsText'];
     $NewsRecord->NewsTags = $_POST['NewsTags'];
     $NewsRecord->publishdate = 'NOW()';
     $NewsRecord->insert();
     $mail = new \PHPMailer();
     $mail->isSMTP();
     $mail->Host = 'smtp.gmail.com';
     $mail->Username = '******';
     $mail->Password = '******';
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = 'ssl';
     $mail->Port = '465';
     $mail->addAddress('*****@*****.**');
     $mail->Body = 'Created news';
     $mail->AltBody = 'Body created';
     $mail->send();
     $mail->clearAddresses();
     header('Location: ./index.php');
 }
Example #4
0
 /**
  * Test address escaping.
  */
 public function testAddressEscaping()
 {
     $this->Mail->Subject .= ': Address escaping';
     $this->Mail->clearAddresses();
     $this->Mail->addAddress('*****@*****.**', 'Tim "The Book" O\'Reilly');
     $this->Mail->Body = 'Test correct escaping of quotes in addresses.';
     $this->buildBody();
     $this->Mail->preSend();
     $b = $this->Mail->getSentMIMEMessage();
     $this->assertTrue(strpos($b, 'To: "Tim \\"The Book\\" O\'Reilly" <*****@*****.**>') !== false);
 }
 function send($from = "", $fromname = "", $sender = false)
 {
     //		function send($from="",$fromname=""){
     if ($this->email != "") {
         $contentType = $this->contentType;
         $email = $this->email;
         $subject = $this->subject;
         $body = $this->body;
         $mail = new PHPMailer();
         if ($from != "") {
             $mail->From = $from;
         } else {
             $mail->From = CFG::FROM;
         }
         if ($fromname != "") {
             $mail->FromName = $fromname;
         } else {
             $mail->FromName = CFG::FROMNAME;
         }
         $mail->ContentType = $contentType;
         $mail->CharSet = 'UTF-8';
         if ($sender === false) {
             $sender = $mail->From;
         }
         $mail->Sender = $sender;
         $mail->Subject = $subject;
         $mail->Body = $body;
         if ($altBody != '') {
             $mail->AltBody = $altbody;
         }
         $mail->clearAddresses();
         if (is_array($email)) {
             foreach ($email as $em) {
                 $mail->addAddress($em);
             }
         } else {
             if (strpos($email, ',') !== false) {
                 $adds = explode(',', $email);
                 foreach ($adds as $em) {
                     $mail->addAddress($em);
                 }
             } else {
                 $mail->addAddress($email);
             }
         }
         if (!is_null($this->attachment)) {
             $tmp = $mail->AddAttachment($this->attachment);
         }
         $mail->Send();
     }
 }
Example #6
0
 function postmail($to, $subject = "", $body = "")
 {
     //$to 表示收件人地址 $subject 表示邮件标题 $body表示邮件正文
     //error_reporting(E_ALL);
     //error_reporting(E_STRICT);
     date_default_timezone_set("Asia/Shanghai");
     //设定时区东八区
     require_once APP . 'controller/class.phpmailer.php';
     require_once APP . "controller/class.smtp.php";
     $mail = new PHPMailer();
     //new一个PHPMailer对象出来
     //$body = preg_replace("[\]",'',$body); //对邮件内容进行必要的过滤
     $mail->CharSet = "UTF-8";
     //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
     $mail->IsSMTP();
     // 设定使用SMTP服务
     $mail->SMTPDebug = 0;
     // 启用SMTP调试功能
     // 1 = errors and messages
     // 2 = messages only
     $mail->SMTPAuth = true;
     // 启用 SMTP 验证功能
     $mail->SMTPSecure = "tls";
     // 安全协议
     $mail->Host = "smtp.sina.com.cn";
     // SMTP 服务器
     $mail->Port = 25;
     // SMTP服务器的端口号
     $mail->WordWrap = 50;
     $mail->Username = "******";
     // SMTP服务器用户名
     $mail->Password = "******";
     // SMTP服务器密码
     $mail->SetFrom('*****@*****.**', '电子设计大赛官方邮箱');
     $mail->AddReplyTo("*****@*****.**", "电子设计大赛官方邮箱");
     $mail->Subject = $subject;
     $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
     // optional, comment out and test
     $mail->MsgHTML($body);
     for ($i = 0; $i < count($to); ++$i) {
         $mail->AddAddress($to[$i][0]);
         $mail->Send();
         $mail->clearAddresses();
     }
 }
Example #7
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 #8
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);
        }
    }
}
Example #9
0
 /**
  * Send an email notification to devs
  * @param STRING $type The type of notification to send ('new', 'close', 'comment', or 'assign')
  * @return INt Number of email actually sent
  */
 public function notify($type)
 {
     global $LANG;
     $iC = new Infos('t_config');
     $iC->loadInfos('nom', 'enable_notify');
     if ($iC->getInfos('value') == 0) {
         return 0;
     }
     $iC->loadInfos('nom', 'project_name');
     $project_name = $iC->getInfos('value');
     $iC->loadInfos('nom', 'language');
     $language = $iC->getInfos('value');
     $mail = new PHPMailer(true);
     $mail->isMail();
     if ($language === 'Francais') {
         $mail->setLanguage('fr', INSTALL_PATH . 'language/phpMailer/');
     }
     $mail->CharSet = 'UTF-8';
     $mail->From = "*****@*****.**";
     $mail->FromName = "Bughunter {$project_name}";
     $mail->isHTML(true);
     switch ($type) {
         case "new":
             $subject = $LANG['Notify_newBug_subject'];
             $bodyTxt = $LANG['Notify_newBug_body'];
             break;
         case "close":
             $subject = $LANG['Notify_killBug_subject'];
             $bodyTxt = $LANG['Notify_killBug_body'];
             break;
         case "comment":
             $subject = $LANG['Notify_comment_subject'];
             $bodyTxt = $LANG['Notify_comment_body'];
             break;
         case "assign":
             $subject = $LANG['Notify_assign_subject'];
             $bodyTxt = $LANG['Notify_assign_body'];
             break;
         default:
             throw new Exception("Notification type unknown.");
     }
     $bugData = $this->getBugData(true);
     $subject = preg_replace('/\\{\\{BUG_ID\\}\\}/', $bugData['id'], $subject);
     $mail->Subject = $subject;
     $template = file_get_contents(INSTALL_PATH . 'mails/template.html');
     $html = preg_replace('/\\{\\{SUBJECT\\}\\}/', $subject, $template);
     $html = preg_replace('/\\{\\{BODY\\}\\}/', $bodyTxt, $html);
     $html = preg_replace('/\\{\\{DATE\\}\\}/', date('Y-m-d'), $html);
     $html = preg_replace('/\\{\\{PROJECT\\}\\}/', $project_name, $html);
     $html = preg_replace('/\\{\\{URL_BH\\}\\}/', preg_replace('/\\/actions$/', '', get_url()), $html);
     $html = preg_replace('/\\{\\{REPORTER\\}\\}/', $bugData['author'], $html);
     $html = preg_replace('/\\{\\{BUG_ID\\}\\}/', $bugData['id'], $html);
     $html = preg_replace('/\\{\\{BUG_TITLE\\}\\}/', $bugData['title'], $html);
     $html = preg_replace('/\\{\\{BUG_DESCR\\}\\}/', $bugData['description'], $html);
     $html = preg_replace('/\\{\\{BUG_LABEL\\}\\}/', $bugData['label']['name'], $html);
     if ($type === "comment") {
         $comm = end($bugData['comment']);
         $html = preg_replace('/\\{\\{COMM_AUTHOR\\}\\}/', $comm['dev']['pseudo'], $html);
         $html = preg_replace('/\\{\\{COMM_MESSAGE\\}\\}/', nl2br($comm['message']), $html);
     }
     $l = new Liste();
     $l->addFiltre('id', '>', '0');
     $l->addFiltre('notify', '=', '1');
     $l->getListe('t_devs');
     $devs = $l->simplifyList();
     if (!$devs) {
         return 0;
     }
     $countSent = 0;
     foreach ($devs as $dev) {
         if ($type === "assign" && $bugData['FK_dev_ID'] != $dev['id']) {
             continue;
         }
         $mail->Body = $html;
         $mail->addAddress($dev['mail']);
         if ($mail->send()) {
             $countSent++;
         }
         $mail->clearAddresses();
         //			file_put_contents(INSTALL_PATH.'data/debugMail_'.$dev['pseudo'].'.html', $html);
     }
     return $countSent;
 }
 /**
  * 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 #11
0
 public function send($isEach = false)
 {
     require_once $this->Module->getPath() . '/classes/phpmailer/class.phpmailer.php';
     if (empty($this->to) == true || $this->subject == null || $this->content == null) {
         return false;
     }
     if (empty($this->from) == true) {
         $this->from = array('*****@*****.**', '알쯔닷컴');
     }
     $phpMailer = new PHPMailer();
     $phpMailer->pluginDir = $this->Module->getPath() . '/classes/phpmailer';
     $phpMailer->isHTML(true);
     $phpMailer->Encoding = 'base64';
     $phpMailer->CharSet = 'UTF-8';
     if (count($this->from) == 2) {
         $phpMailer->setFrom($this->from[0], '=?UTF-8?b?' . base64_encode($this->from[1]) . '?=');
     } else {
         $phpMailer->setFrom($this->from[0]);
     }
     if (count($this->replyTo) == 1) {
         $phpMailer->addReplyTo($this->replyTo[0]);
     } elseif (count($this->replyTo) == 2) {
         $phpMailer->addReplyTo($this->replyTo[0], '=?UTF-8?b?' . base64_encode($this->replyTo[1]) . '?=');
     }
     if (count($this->cc) > 0) {
         for ($i = 0, $loop = count($this->cc); $i < $loop; $i++) {
             if (count($this->cc[$i]) == 2) {
                 $phpMailer->addBcc($this->cc[$i][0], '=?UTF-8?b?' . base64_encode($this->cc[$i][1]) . '?=');
             } else {
                 $phpMailer->addBcc($this->cc[$i][0]);
             }
         }
     }
     if (count($this->bcc) > 0) {
         for ($i = 0, $loop = count($this->bcc); $i < $loop; $i++) {
             if (count($this->bcc[$i]) == 2) {
                 $phpMailer->addBcc($this->bcc[$i][0], '=?UTF-8?b?' . base64_encode($this->bcc[$i][1]) . '?=');
             } else {
                 $phpMailer->addBcc($this->bcc[$i][0]);
             }
         }
     }
     $templet = '<div>{$content}</div>';
     $phpMailer->Subject = '=?UTF-8?b?' . base64_encode($this->subject) . '?=';
     $idx = $this->db()->insert($this->table->send, array('from' => empty($this->from[1]) == true ? $this->from[0] : $this->from[1] . ' <' . $this->from[0] . '>', 'subject' => $this->subject, 'content' => $this->content, 'search' => GetString($this->content, 'index'), 'receiver' => count($this->to), 'reg_date' => time()))->execute();
     if ($isEach == true || count($this->to) == 1) {
         for ($i = 0, $loop = count($this->to); $i < $loop; $i++) {
             $receiverIdx = $this->db()->insert($this->table->receiver, array('parent' => $idx, 'to' => empty($this->to[$i][1]) == true ? $this->to[$i][0] : $this->to[$i][1] . ' <' . $this->to[$i][0] . '>', 'reg_date' => time()))->execute();
             $phpMailer->clearAddresses();
             if (count($this->to[$i]) == 2) {
                 $phpMailer->addAddress($this->to[$i][0], '=?UTF-8?b?' . base64_encode($this->to[$i][1]) . '?=');
             } else {
                 $phpMailer->addAddress($this->to[$i][0]);
             }
             $phpMailer->Body = str_replace('{$content}', $this->content . '<img src="http://' . $_SERVER['HTTP_HOST'] . $this->IM->getProcessUrl('email', 'check', array('receiver' => $receiverIdx)) . '" style="width:1px; height:1px;" />', $templet);
             $result = $phpMailer->send();
             if ($result == true) {
                 $this->db()->update($this->table->receiver, array('status' => 'SUCCESS'))->where('idx', $receiverIdx)->execute();
             } else {
                 $this->db()->update($this->table->receiver, array('status' => 'FAIL', 'result' => $result))->where('idx', $receiverIdx)->execute();
             }
         }
     } else {
         if (count($this->from) == 2) {
             $phpMailer->addAddress($this->from[0], '=?UTF-8?b?' . base64_encode($this->from[1]) . '?=');
         } else {
             $phpMailer->addAddress($this->from[0]);
         }
         for ($i = 0, $loop = count($this->to); $i < $loop; $i++) {
             if (count($this->to[$i]) == 2) {
                 $phpMailer->addBCC($this->to[$i][0], '=?UTF-8?b?' . base64_encode($this->to[$i][1]) . '?=');
             } else {
                 $phpMailer->addBCC($this->to[$i][0]);
             }
         }
     }
     $this->reset();
     return;
 }
Example #12
0
 public function sendMail()
 {
     $siteEmail = SITE_EMAIL;
     $variableEngine = VariableEngine::getInstance();
     $smtpServer = $variableEngine->getVariable('smtpServer');
     if ($smtpServer === false) {
         return false;
     }
     $smtpPort = $variableEngine->getVariable('smtpPort');
     if ($smtpPort === false) {
         return false;
     }
     $smtpUserName = $variableEngine->getVariable('smtpUserName');
     if ($smtpUserName === false) {
         return false;
     }
     $smtpPassword = $variableEngine->getVariable('smtpPassword');
     if ($smtpPassword === false) {
         return false;
     }
     $smtpUseEncryption = $variableEngine->getVariable('smtpUseEncryption');
     if ($smtpUseEncryption === false) {
         return false;
     }
     $smtpUseEncryption = $smtpUseEncryption->getValue();
     if ($smtpUseEncryption === 'false') {
         $encryption = "";
     } else {
         $encryption = "tls";
     }
     $toSend = new PHPMailer();
     $toSend->isSMTP();
     $toSend->Host = $smtpServer->getValue();
     $toSend->SMTPAuth = true;
     $toSend->Username = $smtpUserName->getValue();
     $enc = new Encrypter();
     $toSend->Password = $enc->decrypt($smtpPassword->getValue());
     $toSend->SMTPSecure = $encryption;
     $toSend->Port = intval($smtpPort->getValue());
     $toSend->From = $siteEmail;
     $toSend->FromName = $this->senderName;
     $toSend->addReplyTo($this->senderEmail, $this->senderName);
     $toSend->isHTML(true);
     $toSend->Subject = $this->subject;
     if ($this->isBulkMail) {
         foreach ($this->recipients as $recipient) {
             $toSend->addBCC($recipient);
         }
         $toSend->Body = $this->body;
         $toSend->AltBody = strip_tags($this->body);
         if (!$toSend->send()) {
             $this->errors[] = $toSend->ErrorInfo;
             return false;
         }
         return true;
     }
     $sent = true;
     foreach ($this->recipients as $recipient) {
         $body = $this->doReplacement($recipient);
         $altBody = strip_tags($body);
         $toSend->clearAddresses();
         $toSend->addAddress($recipient);
         $toSend->Body = $body;
         $toSend->AltBody = $altBody;
         if (!$toSend->send()) {
             $this->errors = $toSend->ErrorInfo;
             $sent = false;
         }
     }
     return $sent;
 }
Example #13
0
 function sendSMTPMultiEmail($from_email, $from_name, $data_array)
 {
     //$this->sendMultiEmailCI($from_email,$from_name,$data_array);
     require_once "PHPMailer/class.phpmailer.php";
     try {
         $mail = new PHPMailer(true);
         $mail->IsSMTP();
         // telling the class to use SMTP
         $mail->SMTPDebug = 0;
         // enables SMTP debug information (for testing)
         if (ENVIRONMENT == 'development') {
             $mail->SMTPAuth = true;
             // enable SMTP authentication
             $mail->SMTPSecure = "ssl";
             // sets the prefix to the servier
             $mail->Host = "smtp.gmail.com";
             // sets GMAIL as the SMTP server
             $mail->Port = 465;
             $mail->Username = "******";
             // SMTP server username
             $mail->Password = "******";
             // SMTP server password
         } else {
             $mail->SMTPAuth = true;
             // enable SMTP authentication
             $mail->SMTPSecure = "ssl";
             $mail->Host = "server1.juzonmail.com";
             $mail->Port = 465;
             $mail->Username = "******";
             $mail->Password = "******";
         }
         //$mail->From       = $from_email;
         //$mail->FromName   = "$from_name <$from_email>";//$from_name;
         $mail->CharSet = "UTF-8";
         $mail->AddReplyTo($from_email, $from_name);
         $mail->SetFrom($from_email, $from_name);
         foreach ($data_array as $k => $item) {
             $to = $item['to_email'];
             $mail->AddAddress($to, $item['to_subject']);
             //$mail->AddCC($to);
             $mail->Subject = $item['to_subject'];
             debug($item['to_subject'], "subj.txt");
             $body = $item['body'];
             $mail->MsgHTML($body);
             $mail->IsHTML(true);
             // send as HTML
             $mail->Send();
             $mail->clearAddresses();
             $mail->ClearAttachments();
         }
         return true;
         //echo 'Message has been sent.';
     } catch (phpmailerException $e) {
         return false;
         //echo $e->errorMessage();
     }
 }
 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 #15
0
 public function check()
 {
     $checkStart = (int) $this->_config->get("general", "check_start", 7);
     $checkEnd = (int) $this->_config->get("general", "check_end", 24);
     if ($checkStart > 23) {
         $checkStart = 0;
     }
     if ($checkEnd < 1) {
         $checkEnd = 24;
     }
     $hour = (int) date("G");
     if ($hour < $checkStart || $hour >= $checkEnd) {
         $this->_logger->info("Hors de la plage horaire. Contrôle annulé.");
         return;
     }
     $this->_logger->info("Contrôle des alertes.");
     $this->_checkConnection();
     $users = $this->_userStorage->fetchAll();
     // génération d'URL court pour les SMS
     $curlTinyurl = curl_init();
     curl_setopt($curlTinyurl, CURLOPT_RETURNTRANSFER, 1);
     $storageType = $this->_config->get("storage", "type", "files");
     foreach ($users as $user) {
         if ($storageType == "db") {
             $storage = new \App\Storage\Db\Alert($this->_userStorage->getDbConnection(), $user);
             $this->_logger->info("User: "******"/var/configs/" . $user->getUsername() . ".csv";
             if (!is_file($file)) {
                 continue;
             }
             $storage = new \App\Storage\File\Alert($file);
             $this->_logger->debug("Fichier config: " . $file);
         }
         // configuration des notifications.
         $notifications = array();
         $notifications_params = $user->getOption("notification");
         if ($notifications_params && is_array($notifications_params)) {
             foreach ($notifications_params as $notification_name => $options) {
                 if (!is_array($options)) {
                     continue;
                 }
                 try {
                     $notifications[$notification_name] = \Message\AdapterFactory::factory($notification_name, $options);
                     $this->_logger->debug("notification " . get_class($notifications[$notification_name]) . " activée");
                 } catch (\Exception $e) {
                     $this->_logger->warn("notification " . $notification_name . " invalide");
                 }
             }
         }
         $alerts = $storage->fetchAll();
         $this->_logger->info(count($alerts) . " alerte" . (count($alerts) > 1 ? "s" : "") . " trouvée" . (count($alerts) > 1 ? "s" : ""));
         if (count($alerts) == 0) {
             continue;
         }
         $unique_ads = $user->getOption("unique_ads");
         foreach ($alerts as $i => $alert) {
             $currentTime = time();
             if (!isset($alert->time_updated)) {
                 $alert->time_updated = 0;
             }
             if ((int) $alert->time_updated + (int) $alert->interval * 60 > $currentTime || $alert->suspend) {
                 continue;
             }
             $this->_logger->info("Contrôle de l'alerte " . $alert->url);
             try {
                 $parser = \AdService\ParserFactory::factory($alert->url);
             } catch (\AdService\Exception $e) {
                 $this->_logger->info("\t" . $e->getMessage());
                 continue;
             }
             $this->_logger->debug("Dernière mise à jour : " . (!empty($alert->time_updated) ? date("d/m/Y H:i", (int) $alert->time_updated) : "inconnue"));
             $this->_logger->debug("Dernière annonce : " . (!empty($alert->time_last_ad) ? date("d/m/Y H:i", (int) $alert->time_last_ad) : "inconnue"));
             $alert->time_updated = $currentTime;
             if (!($content = $this->_httpClient->request($alert->url))) {
                 $this->_logger->error("Curl Error : " . $this->_httpClient->getError());
                 continue;
             }
             $cities = array();
             if ($alert->cities) {
                 $cities = array_map("trim", explode("\n", mb_strtolower($alert->cities)));
             }
             $filter = new \AdService\Filter(array("price_min" => $alert->price_min, "price_max" => $alert->price_max, "cities" => $cities, "price_strict" => (bool) $alert->price_strict, "categories" => $alert->getCategories(), "min_id" => $unique_ads ? $alert->last_id : 0));
             $ads = $parser->process($content, $filter, parse_url($alert->url, PHP_URL_SCHEME));
             $countAds = count($ads);
             if ($countAds == 0) {
                 $storage->save($alert);
                 continue;
             }
             $siteConfig = \AdService\SiteConfigFactory::factory($alert->url);
             $newAds = array();
             $time_last_ad = (int) $alert->time_last_ad;
             foreach ($ads as $ad) {
                 if ($time_last_ad < $ad->getDate()) {
                     $newAds[$ad->getId()] = (require DOCUMENT_ROOT . "/app/mail/views/mail-ad.phtml");
                     if ($alert->time_last_ad < $ad->getDate()) {
                         $alert->time_last_ad = $ad->getDate();
                     }
                     if ($unique_ads && $ad->getId() > $alert->last_id) {
                         $alert->last_id = $ad->getId();
                     }
                 }
             }
             if (!$newAds) {
                 $storage->save($alert);
                 continue;
             }
             $countAds = count($newAds);
             $this->_logger->info($countAds . " annonce" . ($countAds > 1 ? "s" : "") . " trouvée" . ($countAds > 1 ? "s" : ""));
             $this->_mailer->clearAddresses();
             $error = false;
             if ($alert->send_mail) {
                 try {
                     $emails = explode(",", $alert->email);
                     foreach ($emails as $email) {
                         $this->_mailer->addAddress(trim($email));
                     }
                 } catch (phpmailerException $e) {
                     $this->_logger->warn($e->getMessage());
                     $error = true;
                 }
                 if (!$error) {
                     if ($alert->group_ads) {
                         $newAdsCount = count($newAds);
                         $subject = "Alert " . $siteConfig->getOption("site_name") . " : " . $alert->title;
                         $message = '<h2>' . $newAdsCount . ' nouvelle' . ($newAdsCount > 1 ? 's' : '') . ' annonce' . ($newAdsCount > 1 ? 's' : '') . ' - ' . date("d/m/Y H:i", $currentTime) . '</h2>
                         <p>Lien de recherche: <a href="' . htmlspecialchars($alert->url, null, "UTF-8") . '">' . htmlspecialchars($alert->url, null, "UTF-8") . '</a></p>
                         <hr /><br />' . implode("<br /><hr /><br />", $newAds) . '<hr /><br />';
                         $this->_mailer->Subject = $subject;
                         $this->_mailer->Body = $message;
                         try {
                             $this->_mailer->send();
                         } catch (phpmailerException $e) {
                             $this->_logger->warn($e->getMessage());
                         }
                     } else {
                         $newAds = array_reverse($newAds, true);
                         foreach ($newAds as $id => $ad) {
                             $subject = ($alert->title ? $alert->title . " : " : "") . $ads[$id]->getTitle();
                             $message = '<h2>Nouvelle annonce - ' . date("d/m/Y H:i", $currentTime) . '</h2>
                             <p>Lien de recherche: <a href="' . htmlspecialchars($alert->url, null, "UTF-8") . '">' . htmlspecialchars($alert->url, null, "UTF-8") . '</a></p>
                             <hr /><br />' . $ad . '<hr /><br />';
                             $this->_mailer->Subject = $subject;
                             $this->_mailer->Body = $message;
                             try {
                                 $this->_mailer->send();
                             } catch (phpmailerException $e) {
                                 $this->_logger->warn($e->getMessage());
                             }
                         }
                     }
                 }
             }
             if ($notifications && ($alert->send_sms_free_mobile || $alert->send_sms_ovh || $alert->send_pushbullet || $alert->send_notifymyandroid || $alert->send_pushover)) {
                 if ($countAds < 5) {
                     // limite à 5 SMS
                     foreach ($newAds as $id => $ad) {
                         $ad = $ads[$id];
                         // récupère l'objet.
                         $url = $ad->getLink();
                         if (false !== strpos($url, "leboncoin")) {
                             $url = "http://mobile.leboncoin.fr/vi/" . $ad->getId() . ".htm";
                         }
                         curl_setopt($curlTinyurl, CURLOPT_URL, "http://tinyurl.com/api-create.php?url=" . $url);
                         if ($url = curl_exec($curlTinyurl)) {
                             $msg = "Nouvelle annonce " . ($alert->title ? $alert->title . " : " : "") . $ad->getTitle();
                             $others = array();
                             if ($ad->getPrice()) {
                                 $others[] = number_format($ad->getPrice(), 0, ',', ' ') . $ad->getCurrency();
                             }
                             if ($ad->getCity()) {
                                 $others[] = $ad->getCity();
                             } elseif ($ad->getCountry()) {
                                 $others[] = $ad->getCountry();
                             }
                             if ($others) {
                                 $msg .= " (" . implode(", ", $others) . ")";
                             }
                             $params = array("title" => "Alerte " . $siteConfig->getOption("site_name"), "description" => "Nouvelle annonce" . ($alert->title ? " pour : " . $alert->title : ""), "url" => $url);
                             foreach ($notifications as $key => $notifier) {
                                 switch ($key) {
                                     case "freeMobile":
                                         $key_test = "send_sms_free_mobile";
                                         break;
                                     case "ovh":
                                         $key_test = "send_sms_ovh";
                                         break;
                                     default:
                                         $key_test = "send_" . $key;
                                 }
                                 if (isset($alert->{$key_test}) && $alert->{$key_test}) {
                                     try {
                                         $notifier->send($msg, $params);
                                     } catch (Exception $e) {
                                         $this->_logger->warn("Erreur sur envoi via " . get_class($notifier) . ": (" . $e->getCode() . ") " . $e->getMessage());
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     // envoi un msg global
                     curl_setopt($curlTinyurl, CURLOPT_URL, "http://tinyurl.com/api-create.php?url=" . $alert->url);
                     if ($url = curl_exec($curlTinyurl)) {
                         $msg = "Il y a " . $countAds . " nouvelles annonces pour votre alerte '" . ($alert->title ? $alert->title : "sans nom") . "'";
                         $params = array("title" => "Alerte " . $siteConfig->getOption("site_name"), "description" => "Nouvelle" . ($countAds > 1 ? "s" : "") . " annonce" . ($countAds > 1 ? "s" : "") . ($alert->title ? " pour : " . $alert->title : ""), "url" => $url);
                         foreach ($notifications as $key => $notifier) {
                             switch ($key) {
                                 case "freeMobile":
                                     $key_test = "send_sms_free_mobile";
                                     break;
                                 case "ovh":
                                     $key_test = "send_sms_ovh";
                                     break;
                                 default:
                                     $key_test = "send_" . $key;
                             }
                             if (isset($alert->{$key_test}) && $alert->{$key_test}) {
                                 try {
                                     $notifier->send($msg, $params);
                                 } catch (Exception $e) {
                                     $this->_logger->warn("Erreur sur envoi via " . get_class($notifier) . ": (" . $e->getCode() . ") " . $e->getMessage());
                                 }
                             }
                         }
                     }
                 }
             }
             $storage->save($alert);
         }
     }
     curl_close($curlTinyurl);
     $this->_mailer->smtpClose();
 }
Example #16
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 #17
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 #18
0
 /**
  * e-mail küldése SMTP-vel
  *
  * @return 
  */
 public function send()
 {
     //include(LIBS . '/PHPMailer/PHPMailerAutoload.php');
     $mail = new PHPMailer();
     if ($this->use_smtp) {
         //Set PHPMailer to use SMTP.
         $mail->isSMTP();
         //Enable SMTP debugging.
         $mail->SMTPDebug = Config::get('email.server.phpmailer_debug_mode');
         //Set SMTP host name
         $mail->Host = Config::get('email.server.smtp_host');
         //Set this to true if SMTP host requires authentication to send email
         $mail->SMTPAuth = Config::get('email.server.smtp_auth');
         // SMTP connection will not close after each email sent, reduces SMTP overhead
         // $mail->SMTPKeepAlive = true;
         //Provide username and password
         $mail->Username = Config::get('email.server.smtp_username');
         $mail->Password = Config::get('email.server.smtp_password');
         //If SMTP requires TLS encryption then set it
         $mail->SMTPSecure = Config::get('email.server.smtp_encryption');
         //Set TCP port to connect to
         $mail->Port = Config::get('email.server.smtp_port');
     } else {
         $mail->isMail();
         // küldés a php mail metódusával
         // $mail->isSendmail(); // küldés sendmail-al
     }
     $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 = $this->from_email;
     //feladó e-mail címe
     $mail->FromName = $this->from_name;
     //feladó neve
     $mail->Subject = $this->subject;
     // Tárgy megadása
     $mail->isHTML(true);
     // Set email format to HTML
     if (!empty($this->attachments)) {
         foreach ($this->attachments as $value) {
             $mail->addAttachment($this->attachments_path . $value);
         }
     }
     // levél tartalom beállítása
     $mail->Body = $this->_load_template_with_data($this->template, $this->template_data);
     //$mail->AltBody = '';
     $mail->addAddress($this->to_email, $this->to_name);
     // Add a recipient (Name is optional)
     // $mail->addAddress($admin_email);
     // final sending and check
     if ($mail->send()) {
         $mail->clearAddresses();
         return true;
     } else {
         $mail->clearAddresses();
         //var_dump($mail->ErrorInfo);
         return false;
     }
 }
 /**
  *	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 #20
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);
        }
    }
}
Example #21
0
 public function send($clearAddresses = true)
 {
     $this->_applyReplacements();
     $result = (bool) parent::send();
     if ($clearAddresses) {
         parent::clearAddresses();
     }
     if (!$result) {
         iaDebug::debug($this->ErrorInfo, 'Email submission');
     }
     return $result;
 }
Example #22
0
 /**
  * ฟังก์ชั่นส่งเมล์แบบกำหนดรายละเอียดเอง
  *
  * @param string $mailto ที่อยู่อีเมล์ผู้รับ  คั่นแต่ละรายชื่อด้วย ,
  * @param string $replyto ที่อยู่อีเมล์สำหรับการตอบกลับจดหมาย ถ้าระบุเป็นค่าว่างจะใช้ที่อยู่อีเมล์จาก noreply_email
  * @param string $subject หัวข้อจดหมาย
  * @param string $msg รายละเอียดของจดหมาย (รองรับ HTML)
  * @return string สำเร็จคืนค่าว่าง ไม่สำเร็จ คืนค่าข้อความผิดพลาด
  */
 public static function send($mailto, $replyto, $subject, $msg)
 {
     $charset = empty(self::$cfg->email_charset) ? 'utf-8' : strtolower(self::$cfg->email_charset);
     if (empty($replyto)) {
         $replyto = array(self::$cfg->noreply_email, strip_tags(self::$cfg->web_title));
     } elseif (preg_match('/^(.*)<(.*?)>$/', $replyto, $match)) {
         $replyto = array($match[1], empty($match[2]) ? $match[1] : $match[2]);
     } else {
         $replyto = array($replyto, $replyto);
     }
     if ($charset !== 'utf-8') {
         $subject = iconv('utf-8', $charset, $subject);
         $msg = iconv('utf-8', $charset, $msg);
         $replyto[1] = iconv('utf-8', $charset, $replyto[1]);
     }
     $messages = array();
     if (empty(self::$cfg->email_use_phpMailer)) {
         // ส่งอีเมล์ด้วยฟังก์ชั่นของ PHP
         foreach (explode(',', $mailto) as $email) {
             $headers = "MIME-Version: 1.0\r\n";
             $headers .= "Content-type: text/html; charset={$charset}\r\n";
             $headers .= "Content-Transfer-Encoding: quoted-printable\r\n";
             $headers .= "To: {$email}\r\n";
             $headers .= "From: {$replyto['1']}\r\n";
             $headers .= "Reply-to: {$replyto['0']}\r\n";
             $headers .= "X-Mailer: PHP mailer\r\n";
             if (!@mail($email, $subject, $msg, $headers)) {
                 $messages = array(Language::get('Unable to send mail'));
             }
         }
     } else {
         // ส่งอีเมล์ด้วย PHPMailer
         include_once VENDOR_DIR . 'PHPMailer/class.phpmailer.php';
         // Create a new PHPMailer instance
         $mail = new \PHPMailer();
         // Tell PHPMailer to use SMTP
         $mail->isSMTP();
         // charset
         $mail->CharSet = $charset;
         // use html
         $mail->IsHTML();
         $mail->SMTPAuth = empty(self::$cfg->email_SMTPAuth) ? false : true;
         if ($mail->SMTPAuth) {
             $mail->Username = self::$cfg->email_Username;
             $mail->Password = self::$cfg->email_Password;
             $mail->SMTPSecure = self::$cfg->email_SMTPSecure;
         }
         if (!empty(self::$cfg->email_Host)) {
             $mail->Host = self::$cfg->email_Host;
         }
         if (!empty(self::$cfg->email_Port)) {
             $mail->Port = self::$cfg->email_Port;
         }
         $mail->AddReplyTo($replyto[0], $replyto[1]);
         $mail->SetFrom(self::$cfg->noreply_email, strip_tags(self::$cfg->web_title));
         // subject
         $mail->Subject = $subject;
         // message
         $mail->MsgHTML(preg_replace('/(<br([\\s\\/]{0,})>)/', "\$1\r\n", $msg));
         $mail->AltBody = strip_tags($msg);
         foreach (explode(',', $mailto) as $email) {
             if (preg_match('/^(.*)<(.*)>$/', $email, $match)) {
                 if ($mail->ValidateAddress($match[1])) {
                     $mail->AddAddress($match[1], $match[2]);
                 }
             } else {
                 if ($mail->ValidateAddress($email)) {
                     $mail->AddAddress($email, $email);
                 }
             }
             if (false === $mail->send()) {
                 $messages[$mail->ErrorInfo] = $mail->ErrorInfo;
             }
             $mail->clearAddresses();
         }
     }
     return empty($messages) ? '' : implode("\n", $messages);
 }
Example #23
0
     }
     if (!empty($options["password"])) {
         $mailer->SMTPAuth = true;
         $mailer->Password = $options["password"];
     }
     if (!empty($options["secure"])) {
         $mailer->SMTPSecure = $options["secure"];
     }
     if (!empty($options["from"])) {
         $mailer->Sender = $options["from"];
         $mailer->From = $options["from"];
     }
     if (empty($_POST["testMail"])) {
         $errors["testMail"] = "Indiquez une adresse e-mail pour l'envoi du test.";
     } else {
         $mailer->clearAddresses();
         $mailer->addAddress($_POST["testMail"]);
         if ($options["from"]) {
             $mailer->FromName = $options["from"];
         }
         $mailer->Subject = "Test d'envoi de mail";
         $mailer->Body = "Bravo.\nVotre configuration mail est validée.";
         try {
             $mailer->send();
             $testSended = true;
         } catch (phpmailerException $e) {
             $testError = $e->getMessage();
         }
     }
 } else {
     $config->set("mailer", "smtp", array("host" => $options["host"], "port" => $options["port"], "username" => $options["username"], "password" => $options["password"], "secure" => $options["secure"]));
Example #24
0
function send_email_revision($revision, $only_default = "", $status = "")
{
    //var_dump($revision);
    // die();
    require_once 'include/PHPMailer/PHPMailerAutoload.php';
    $email_to_default = def_value("default_email", "hodnota");
    mysql_query("BEGIN");
    $data = sql_query("SELECT id_obj, meno, adresa, mesto, psc, ico, dic, telefon, email, komentar,\r\n                                vystavil, vlastne_cislo_obj, doruc_meno, doruc_adresa, doruc_mesto, \r\n                                doruc_psc,\r\n                                    DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum\r\n                                    FROM revizia \r\n                                    WHERE id={$revision} \r\n                                    LIMIT 1");
    $data_row = sql_query("SELECT id, ks, id_product_type, id_product, id_product_delivery, atyp_text\r\n                                    FROM objednavka_row \r\n                                    WHERE id_revizia={$revision}");
    $data = $data[0];
    $fieldsets_c = count($data_row);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $ks[$i] = $data_row[$i][ks];
        $product_type[$i] = $data_row[$i][id_product_type];
        $product[$i] = $data_row[$i][id_product];
        $product_delivery[$i] = $data_row[$i][id_product_delivery];
        $atyp_text[$i] = $data_row[$i][atyp_text];
        $data_row_option = sql_query("SELECT id_product_atribute, id_product_atribute_option \r\n                                    FROM objednavka_row_atribute \r\n                                    WHERE id_revizia=\"{$revision}\" AND id_objednavka_row=\"{$data_row[$i][id]}\"");
        //dd($form_data_row_option);
        foreach ($data_row_option as $option) {
            $data_rows[$i][$option["id_product_atribute"]] = $option["id_product_atribute_option"];
        }
    }
    $data[ks_all] = $ks;
    $data[product_type_all] = $product_type;
    $data[product_all] = $product;
    $data[product_delivery_all] = $product_delivery;
    $data[atyp_text_all] = $atyp_text;
    $data[product_atribute_options_all] = $data_rows;
    $files = sql_query("SELECT meno, meno_old, pripona \r\n                                FROM subor\r\n                                WHERE id_obj=" . $data["id_obj"] . "");
    //var_dump($data);
    $data_obj = sql_query("SELECT DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum, c_obj, status,\r\n                                    DATE_FORMAT(datum, '%Y') AS rok\r\n                                    FROM objednavka \r\n                                    WHERE id=" . $data["id_obj"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    $secure_key = sql_query("SELECT secure_key\r\n                                    FROM objednavka_secure\r\n                                    WHERE id_obj=" . $data["id_obj"] . " AND \r\n                                          id_revizia={$revision} LIMIT 1");
    $secure_key = $secure_key[0][secure_key];
    $message = "<html><body>";
    $message .= "<img src=\"http://" . $_SERVER['HTTP_HOST'] . "/assets/images/logo.jpg\">";
    $message .= "<h1>Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . "</h1>";
    $message .= "<h3><a href=\"http://www.benab.sk/objednavka\">www.benab.sk/objednavka</a></h3>";
    if (!empty($data["vlastne_cislo_obj"])) {
        $message .= "Vaše číslo objednávky: " . $data["vlastne_cislo_obj"] . "<br>";
    }
    $message .= "zo dňa: " . $data_obj["datum"] . "<br><br>";
    $message .= "<table><tr>";
    $message .= "<td style=\"width: 400px;\"><strong>Dodávateľ</strong><br>";
    $message .= "<table><tr><td>" . def_value("default_firma", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_adresa", "hodnota") . "<br>" . def_value("default_mesto", "hodnota") . "</td></tr>";
    $message .= "<tr><td>IČO: " . def_value("default_ico", "hodnota") . "<br> DIČ: " . def_value("default_dic", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_telefon", "hodnota") . "<br> " . def_value("default_mobil", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_email", "hodnota") . "<br> " . def_value("default_email_2", "hodnota") . "</td></tr>";
    $message .= "</table><br><br></td>";
    $message .= "<td style=\"width: 50%;\"><strong>Objednávateľ:</strong>";
    $message .= "<table><tr><td></td><td>" . $data["meno"] . "</td></tr>";
    $message .= "<tr><td></td><td>" . $data["adresa"] . "</td></tr>";
    $message .= "<tr><td></td><td>" . $data["psc"] . " " . $data["mesto"] . "</td></tr>";
    $message .= "<tr><td>IČO</td><td>" . $data["ico"] . "</td></tr>";
    $message .= "<tr><td>DIČ</td><td>" . $data["dic"] . "</td></tr>";
    $message .= "<tr><td>tel.</td><td>" . $data["telefon"] . "</td></tr>";
    $message .= "<tr><td>email:</td><td>" . $data["email"] . "</td></tr>";
    $message .= "<tr><td>vystavil:</td><td>" . $data["vystavil"] . "</td></tr>";
    $message .= "</table><br><strong>Adresa doručenia:</strong>";
    $message .= "<table><tr><td>" . $data["doruc_meno"] . "</td></tr>";
    $message .= "<tr><td>" . $data["doruc_adresa"] . "</td></tr>";
    $message .= "<tr><td>" . $data["doruc_psc"] . " " . $data["doruc_mesto"] . "</td></tr>";
    $message .= "</table><br></td>";
    $message .= "</tr></table><br><br>";
    $message .= "<table style=\"font-size: 10pt;\">\r\n               <tr style=\"border-bottom: solid 1px darkslategrey ;\">\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\"></th>               \r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 400px;\">Produkt</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 60px;\">Množstvo</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 80px;\">Doprava</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 100px;\">Poznámka</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%;\"></th>\r\n               </tr>";
    $fieldsets_c = count($data["ks_all"]);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $poradie = 0;
        $poradie = $i + 1;
        $message .= "<tr>\r\n                     <td class=\"form_poradie\">{$poradie}. </td>\r\n                     ";
        $product_type = sql_query("SELECT meno FROM product_type WHERE id=" . sec_sql(sec_input($data["product_type_all"][$i])) . " LIMIT 1");
        $product_type = $product_type[0];
        $product = sql_query("SELECT meno FROM product WHERE id=" . sec_sql(sec_input($data["product_all"][$i])) . " LIMIT 1")[0];
        $options_str = array();
        //var_dump($data);
        if (!isset($data["product_atribute_options_all"][$i]) or empty($data["product_atribute_options_all"][$i])) {
            $data["product_atribute_options_all"][$i] = array();
        }
        foreach ($data["product_atribute_options_all"][$i] as $option) {
            //var_dump($option);
            $options_str[] = sql_query("SELECT meno FROM product_atribute_option WHERE id=" . sec_sql(sec_input($option)) . " LIMIT 1")[0]["meno"];
        }
        $options_str = empty($options_str) ? "" : " (" . join(", ", $options_str) . ")";
        //var_dump($options_str);
        $message .= "<td class=\"form_nazov_siroky\">" . $product_type["meno"] . " " . $product["meno"] . "" . $options_str . "</td>";
        $product_delivery = sql_query("SELECT meno FROM product_delivery WHERE id=" . sec_sql(sec_input($data["product_delivery_all"][$i])) . " LIMIT 1");
        $product_delivery = $product_delivery[0];
        $message .= "<td style=\"text-align: center\">" . sec_input($data["ks_all"][$i]) . " ks</td>";
        $message .= "<td style=\"text-align: center\">" . $product_delivery["meno"] . "</td>";
        $message .= "<td class=\"form_nazov\">" . sec_input($data["atyp_text_all"][$i]) . "</td>";
        $message .= "<td class=\"td_vypocet\">" . ($vypocet > 0 ? $vypocet_final : "") . "</td>";
        $message .= "</tr>";
    }
    //var_dump($vypocet_paska_sum);
    //$message .= "<td class=\"td_vypocet\">".($vypocet>0 ? $vypocet_final : "" )."</td>";
    $message .= "</tr>";
    $message .= "</table><br>";
    $message .= "<br>" . $data["komentar"] . "<br><br>";
    if ($data_obj["status"] == def_value("default_obj_status_rozpracovana", "hodnota")) {
        $message .= "<h2>Objednávka je uložená a ešte nebola Vami potvrdená.</h2>\r\n                                Pre potvrdenie objednávky, alebo jej ďalšie úpravy kliknite na túto adresu:\r\n                                ";
    } else {
        $message .= "Pre dodatočnú úpravu objednávky použite prosím túto adresu:";
    }
    $message .= "<br><a href=\"http://" . $_SERVER['HTTP_HOST'] . "/?vyber=formular&secure_key={$secure_key}\">\r\n                                    http://" . $_SERVER['HTTP_HOST'] . "/?vyber=formular&secure_key={$secure_key}\r\n                                </a>";
    $message .= "<br>Ak sme už Vašu objednávku spracovali a je v procese výroby, jej úpravy už nie su možné.<br>\r\n                         <br><br>";
    $message .= "email vytvorený: " . date("j. n. Y - H:i") . "<br>";
    $message .= "</body></html>";
    mysql_query("COMMIT");
    $headers = "From: \"" . $data["meno"] . "\" <" . $data["email"] . ">\r\n";
    $headers .= "Reply-To: " . $data["email"] . "\r\n";
    //$headers .= "CC: scooti@stonline.sk\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->CharSet = "UTF-8";
    $mail->SMTPDebug = 0;
    $mail->SMTPAuth = true;
    //$mail->SMTPSecure = 'ssl';
    $mail->Host = def_value("default_email_host", "hodnota");
    $mail->Port = def_value("default_email_port", "hodnota");
    $mail->Username = def_value("default_email_username", "hodnota");
    $mail->Password = def_value("default_email_password", "hodnota");
    $mail->isHTML(true);
    $mail->setLanguage('sk', 'language/');
    $mail->SetFrom(def_value("default_email", "hodnota"), def_value("default_firma", "hodnota"));
    if (!empty($status) and $status == "rozpracovana") {
        $email_to = $data["email"];
        $email_subject = "" . def_value("default_firma", "hodnota") . " - Rozpracovaná Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . " - " . def_value("default_firma", "hodnota") . "";
        $headers = "From: \"" . def_value("default_firma", "hodnota") . "\" <" . def_value("default_email", "hodnota") . ">\r\n";
        $headers .= "Reply-To: " . def_value("default_email", "hodnota") . "\r\n";
        //$headers .= "CC: scooti@stonline.sk\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
        $mail->Subject = $email_subject;
        $mail->Body = $message;
        $mail->AddAddress($email_to);
        $mail->Send();
        //mail($email_to, $email_subject, $message, $headers);
    } else {
        /*
                $email_to = $email_to_default;
                $email_subject = "".substr(def_value("default_firma", "hodnota"), 0, 5)." - Potvrdenie objednávky č. ".$data_obj["c_obj"]."/".$data_obj["rok"]." od ".$data["meno"]."";
                if (!empty($status) and $status=="cp") 
                    $email_subject = "Žiadosť o Cenovú ponuku pre objednávku č. ".$data_obj["c_obj"]." od ".$data["meno"]." - ".def_value("default_firma", "hodnota")."";
                
                $mail->Subject = $email_subject;
                $mail->Body = $message;
                
                
                 POSLANIE DO FIRMY
                $mail->AddAddress($email_to);
                $mail->Send();
        * 
        */
        //
        //
        //mail($email_to, $email_subject, $message, $headers);
        //var_dump($email_to);
        //var_dump($data["email"]);
        if ($only_default != 1 and $data["email"] != $email_to) {
            $email_to = $data["email"];
            $email_subject = "" . substr(def_value("default_firma", "hodnota"), 0, 5) . " - Potvrdenie objednávky č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . "";
            if (!empty($status) and $status == "cp") {
                $email_subject = "Žiadosť o Cenovú ponuku pre objednávku č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . " - " . def_value("default_firma", "hodnota") . "";
            }
            $headers = "From: \"" . def_value("default_firma", "hodnota") . "\" <" . def_value("default_email", "hodnota") . ">\r\n";
            $headers .= "Reply-To: " . def_value("default_email", "hodnota") . "\r\n";
            //$headers .= "CC: scooti@stonline.sk\r\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
            //mail($email_to, $email_subject, $message, $headers);
            $mail->clearAddresses();
            $mail->Subject = $email_subject;
            $mail->Body = $message;
            $mail->AddAddress($email_to);
            $mail->Send();
            //var_dump($email_to);
            //var_dump($data["email"]);
        }
    }
    echo "Email bol úspešne odoslaný na adresu: {$email_to}";
}
Example #25
0
function send_email_revision($revision, $only_kraf = "", $status = "")
{
    //var_dump($revision);
    // die();
    require_once 'include/PHPMailer/PHPMailerAutoload.php';
    $email_to_kraf = def_value("default_email", "hodnota");
    mysql_query("BEGIN");
    $data = sql_query("SELECT id_obj, meno, adresa, ico_icdph, telefon, email, id_material as material,\r\n                                    id_vyrobca as vyrobca, id_dekor as dekor, dekor_vlastny, objednavka_typ, objednavka_doprava, komentar,\r\n                                    DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum\r\n                                    FROM revizia \r\n                                    WHERE id={$revision} \r\n                                    LIMIT 1");
    $data_narez = sql_query("SELECT ks, dlzka, sirka, nazov, poznamka, hrubka, orientacia,\r\n                                    hrana1, hrana2, hrana3, hrana4\r\n                                    FROM porez \r\n                                    WHERE id_revizia={$revision}");
    $data = $data[0];
    $fieldsets_c = count($data_narez);
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $ks[$i] = $data_narez[$i][ks];
        $dlzka[$i] = $data_narez[$i][dlzka];
        $sirka[$i] = $data_narez[$i][sirka];
        $nazov[$i] = $data_narez[$i][nazov];
        $poznamka[$i] = $data_narez[$i][poznamka];
        $hrubka[$i] = $data_narez[$i][hrubka];
        $orientacia[$i] = $data_narez[$i][orientacia];
        $hrana1[$i] = $data_narez[$i][hrana1];
        $hrana2[$i] = $data_narez[$i][hrana2];
        $hrana3[$i] = $data_narez[$i][hrana3];
        $hrana4[$i] = $data_narez[$i][hrana4];
    }
    $data[ks_all] = $ks;
    $data[dlzka_all] = $dlzka;
    $data[sirka_all] = $sirka;
    $data[nazov_all] = $nazov;
    $data[poznamka_all] = $poznamka;
    $data[hrubka_all] = $hrubka;
    $data[orientacia_all] = $orientacia;
    $data[hrana1_all] = $hrana1;
    $data[hrana2_all] = $hrana2;
    $data[hrana3_all] = $hrana3;
    $data[hrana4_all] = $hrana4;
    //var_dump($data);
    $files = sql_query("SELECT meno, meno_old, pripona \r\n                                FROM subor\r\n                                WHERE id_obj=" . $data["id_obj"] . "");
    //var_dump($data);
    $data_obj = sql_query("SELECT DATE_FORMAT(datum, '%d. %m. %Y, %H:%i') AS datum, c_obj, status,\r\n                                    DATE_FORMAT(datum, '%Y') AS rok\r\n                                    FROM objednavka \r\n                                    WHERE id=" . $data["id_obj"] . " LIMIT 1");
    $data_obj = $data_obj[0];
    $secure_key = sql_query("SELECT secure_key\r\n                                    FROM objednavka_secure\r\n                                    WHERE id_obj=" . $data["id_obj"] . " AND \r\n                                          id_revizia={$revision} LIMIT 1");
    $secure_key = $secure_key[0][secure_key];
    $message = "<html><body>";
    $message .= "<img src=\"http://" . def_value("default_url", "hodnota") . "/assets/images/logo.jpg\">";
    $message .= "<h1>Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . "</h1>";
    $message .= "zo dňa: " . $data_obj["datum"] . "<br><br>";
    $message .= "<table><tr>";
    $message .= "<td style=\"width: 400px;\"><strong>Dodávateľ</strong><br>";
    $message .= "<table><tr><td>" . def_value("default_firma", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_adresa", "hodnota") . "<br>" . def_value("default_mesto", "hodnota") . "</td></tr>";
    $message .= "<tr><td>IČO: " . def_value("default_ico", "hodnota") . "<br> DIČ: " . def_value("default_dic", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_telefon", "hodnota") . "<br> " . def_value("default_mobil", "hodnota") . "</td></tr>";
    $message .= "<tr><td>" . def_value("default_email", "hodnota") . "<br> " . def_value("default_email_2", "hodnota") . "</td></tr>";
    $message .= "</table><br><br></td>";
    $message .= "<td style=\"width: 50%;\"><strong>Objednávateľ:</strong>";
    $message .= "<table><tr><td>" . $data["meno"] . "</td></tr>";
    $message .= "<tr><td>" . $data["adresa"] . "</td></tr>";
    $message .= "<tr><td>" . $data["ico_icdph"] . "</td></tr>";
    $message .= "<tr><td>" . $data["telefon"] . "</td></tr>";
    $message .= "<tr><td>" . $data["email"] . "</td></tr>";
    $message .= "</table><br><br></td>";
    $message .= "</tr></table>";
    $message .= "<strong>Materiál:</strong>";
    $material = sql_query("SELECT meno FROM material WHERE id=" . sec_sql(sec_input($data["material"])) . " LIMIT 1");
    $material = $material[0];
    $message .= "<table><tr><td>" . $material["meno"] . "</td></tr>";
    $vyrobca = sql_query("SELECT meno FROM vyrobca WHERE id=\"" . sec_sql(sec_input($data["vyrobca"])) . "\" LIMIT 1");
    $vyrobca = $vyrobca[0];
    $dekor = sql_query("SELECT meno FROM dekor WHERE id=" . sec_sql(sec_input($data["dekor"])) . " LIMIT 1");
    $dekor = $dekor[0];
    $message .= "<tr><td>" . $vyrobca["meno"] . " " . $dekor["meno"] . "</td></tr>";
    $message .= "<tr><td>" . $data["dekor_vlastny"] . "</td></tr>";
    $message .= "<tr><td>" . $data["objednavka_typ"] . " / " . (empty($data["objednavka_doprava"]) ? "bez dopravy" : "s dopravou") . "</td></tr>";
    $message .= "</table><br><br>";
    $message .= "<table style=\"font-size: 10pt;\">\r\n               <tr style=\"border-bottom: solid 1px darkslategrey ;\">\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\"></th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 40px;\">ks</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 180px;\">rozmer</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 150px;\">Názov</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 150px;\">Poznámka</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 50px;\">hrúbka</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 50px;\">orient.</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\">dolná</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\">pravá</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\">horná</th>\r\n               <th style=\"background-color: lightsteelblue; color: white; padding:5px; font-size: 90%; width: 20px;\">ľava</th>\r\n               </tr>";
    for ($i = 0; $i < $fieldsets_c; $i++) {
        $poradie = 0;
        $poradie = $i + 1;
        $message .= "<tr>\r\n                    <td class=\"form_poradie\">{$poradie}. </td>\r\n                    <td class=\"form_ks\">" . sec_input($data["ks_all"][$i]) . "</td>\r\n                    <td class=\"form_rozmer\">" . sec_input($data["dlzka_all"][$i]) . " x " . $data["sirka_all"][$i] . " mm</td>\r\n                    <td class=\"form_nazov\">" . sec_input($data["nazov_all"][$i]) . "</td>\r\n                    <td class=\"form_nazov\">" . sec_input($data["poznamka_all"][$i]) . "</td>";
        $hrubka = sql_query("SELECT meno FROM hrubka WHERE id=" . sec_sql(sec_input($data["hrubka_all"][$i])) . " LIMIT 1");
        $hrubka = $hrubka[0];
        $message .= "\r\n                    <td class=\"form_hrana\">" . $hrubka["meno"] . "</td>";
        $orientacia = sql_query("SELECT meno FROM orientacia WHERE id=" . sec_sql(sec_input($data["orientacia_all"][$i])) . " LIMIT 1");
        $orientacia = $orientacia[0];
        $message .= "\r\n                    <td class=\"form_hrana\">" . $orientacia["meno"] . "</td>";
        $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana1_all"][$i])) . " LIMIT 1");
        $hrana = $hrana[0];
        $message .= "<td class=\"form_hrana\">" . $hrana[meno] . "</td>";
        $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana2_all"][$i])) . " LIMIT 1");
        $hrana = $hrana[0];
        $message .= "<td class=\"form_hrana\">" . $hrana[meno] . "</td>";
        $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana3_all"][$i])) . " LIMIT 1");
        $hrana = $hrana[0];
        $message .= "\r\n                    <td class=\"form_hrana\">" . $hrana[meno] . "</td>";
        $hrana = sql_query("SELECT meno FROM hrana WHERE id=" . sec_sql(sec_input($data["hrana4_all"][$i])) . " LIMIT 1");
        $hrana = $hrana[0];
        $message .= "<td class=\"form_hrana\">" . $hrana[meno] . "</td>";
        $vypocet = $data["dlzka_all"][$i] * $data["sirka_all"][$i] / 1000000;
        $vypocet = $vypocet * $data["ks_all"][$i];
        if ($data["hrubka_all"][$i] == def_value("default_duplak", "hodnota")) {
            $paska = 0;
            if ($data[hrana1_all][$i] > 0) {
                $paska = $paska + $data[dlzka_all][$i];
            }
            if ($data[hrana3_all][$i] > 0) {
                $paska = $paska + $data[dlzka_all][$i];
            }
            if ($data[hrana2_all][$i] > 0) {
                $paska = $paska + $data[sirka_all][$i];
            }
            if ($data[hrana4_all][$i] > 0) {
                $paska = $paska + $data[sirka_all][$i];
            }
            $vypocet_duplak = $data["dlzka_all"][$i] * $data["sirka_all"][$i] / 1000000;
            $vypocet_duplak = $vypocet_duplak * $data["ks_all"][$i];
            $vypocet = ($data["dlzka_all"][$i] + 20) * ($data["sirka_all"][$i] + 20) / 1000000;
            $vypocet = $vypocet * ($data["ks_all"][$i] * 2);
            $vypocet_duplak_sum = $vypocet_duplak_sum + $vypocet_duplak;
            $vypocet_paska_sum = $vypocet_paska_sum + $paska * $data["ks_all"][$i] / 1000;
        } else {
            $hrany = sql_query("SELECT id, meno FROM hrana where vymaz=0 and zobraz_vo_formulari=1");
            //var_dump($hrany);
            foreach ($hrany as $hrana) {
                $paska_normal[$hrana["meno"]] = 0;
                if ($data[hrana1_all][$i] > 0 and $data[hrana1_all][$i] == $hrana["id"]) {
                    $paska_normal[$hrana["meno"]] = $paska_normal[$hrana["meno"]] + $data[dlzka_all][$i];
                }
                if ($data[hrana3_all][$i] > 0 and $data[hrana3_all][$i] == $hrana["id"]) {
                    $paska_normal[$hrana["meno"]] = $paska_normal[$hrana["meno"]] + $data[dlzka_all][$i];
                }
                if ($data[hrana2_all][$i] > 0 and $data[hrana2_all][$i] == $hrana["id"]) {
                    $paska_normal[$hrana["meno"]] = $paska_normal[$hrana["meno"]] + $data[sirka_all][$i];
                }
                if ($data[hrana4_all][$i] > 0 and $data[hrana4_all][$i] == $hrana["id"]) {
                    $paska_normal[$hrana["meno"]] = $paska_normal[$hrana["meno"]] + $data[sirka_all][$i];
                }
                $vypocet_paska_normal_sum[$hrana["meno"]] = $vypocet_paska_normal_sum[$hrana["meno"]] + $paska_normal[$hrana["meno"]] * $data["ks_all"][$i] / 1000;
                //var_dump($paska_normal);
                //var_dump($vypocet_paska_normal_sum);
            }
        }
        $vypocet_sum = $vypocet_sum + $vypocet;
        $vypocet_final = round($vypocet, 2) . " m2";
        //var_dump($vypocet_paska_sum);
        //$message .= "<td class=\"td_vypocet\">".($vypocet>0 ? $vypocet_final : "" )."</td>";
        $message .= "</tr>";
    }
    $message .= "</table><br>";
    $message .= "<div class=\"form_vypocet_sum\">" . ($vypocet_sum > 0 ? "Spolu: " . round($vypocet_sum, 2) . " m2" : "") . "</div>";
    $message .= "<div class=\"form_vypocet_sum\">";
    if (!empty($vypocet_paska_normal_sum)) {
        foreach ($vypocet_paska_normal_sum as $key => $paska_view) {
            $message .= "{$key} opáskovanie: " . round($paska_view, 2) . " m<br>";
        }
    }
    $message .= "</div>";
    $message .= "<div class=\"form_vypocet_sum_duplak\">" . ($vypocet_duplak_sum > 0 ? "Duplák spracovanie: " . round($vypocet_duplak_sum, 2) . " m2" : "") . "<br>\r\n                                                                " . ($vypocet_paska_sum > 0 ? "Duplák opaskovanie: " . round($vypocet_paska_sum, 2) . " m" : "") . "</div>";
    $message .= "<br>" . $data["komentar"] . "<br><br>";
    if (count($files) > 0) {
        $message .= "<div class=\"print_subory\">\r\n               Počet príloh objednávky: " . count($files) . "<br>";
        for ($i = 0; $i < count($files); $i++) {
            $message .= " - " . $files[$i]["meno_old"] . "<br>";
        }
        $message .= "</div><br><br>";
    }
    if ($data_obj["status"] == def_value("default_obj_status_rozpracovana", "hodnota")) {
        $message .= "<h2>Objednávka je uložená a ešte nebola Vami potvrdená.</h2>\r\n                                Pre potvrdenie objednávky, alebo jej ďalšie úpravy kliknite na túto adresu:\r\n                                ";
    } else {
        $message .= "Pre dodatočnú úpravu objednávky použite prosím túto adresu:";
    }
    $message .= "<br><a href=\"http://" . def_value("default_url", "hodnota") . "/?vyber=formular&secure_key={$secure_key}\">\r\n                                    http://" . def_value("default_url", "hodnota") . "/?vyber=formular&secure_key={$secure_key}\r\n                                </a>";
    $message .= "<br>Ak sme už Vašu objednávku spracovali a je v procese výroby, jej úpravy už nie su možné.<br>\r\n                         <br><br>";
    $message .= "email vytvorený: " . date("j. n. Y - H:i") . "<br>";
    $message .= "</body></html>";
    mysql_query("COMMIT");
    $headers = "From: \"" . $data["meno"] . "\" <" . $data["email"] . ">\r\n";
    $headers .= "Reply-To: " . $data["email"] . "\r\n";
    //$headers .= "CC: scooti@stonline.sk\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->CharSet = "UTF-8";
    $mail->SMTPDebug = false;
    $mail->SMTPAuth = true;
    //$mail->SMTPSecure = 'ssl';
    $mail->Host = def_value("default_email_host", "hodnota");
    $mail->Port = def_value("default_email_port", "hodnota");
    $mail->Username = def_value("default_email_username", "hodnota");
    $mail->Password = def_value("default_email_password", "hodnota");
    $mail->isHTML(true);
    $mail->setLanguage('sk', 'language/');
    $mail->SetFrom(def_value("default_email", "hodnota"), def_value("default_firma", "hodnota"));
    if (!empty($status) and $status == "rozpracovana") {
        $email_to = $data["email"];
        $email_subject = "Rozpracovaná Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . " - " . def_value("default_firma", "hodnota") . "";
        $headers = "From: \"" . def_value("default_firma", "hodnota") . "\" <" . def_value("default_email", "hodnota") . ">\r\n";
        $headers .= "Reply-To: " . def_value("default_email", "hodnota") . "\r\n";
        //$headers .= "CC: scooti@stonline.sk\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
        $mail->Subject = $email_subject;
        $mail->Body = $message;
        $mail->AddAddress($email_to);
        $mail->Send();
        //mail($email_to, $email_subject, $message, $headers);
    } else {
        $email_to = $email_to_kraf;
        $email_subject = "Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . " od " . $data["meno"] . " - " . def_value("default_firma", "hodnota") . "";
        if (!empty($status) and $status == "cp") {
            $email_subject = "Žiadosť o Cenovú ponuku pre objednávku č. " . $data_obj["c_obj"] . " od " . $data["meno"] . " - " . def_value("default_firma", "hodnota") . "";
        }
        $mail->Subject = $email_subject;
        $mail->Body = $message;
        $mail->AddAddress($email_to);
        $mail->Send();
        //mail($email_to, $email_subject, $message, $headers);
        //var_dump($email_to);
        //var_dump($data["email"]);
        if ($only_kraf != 1 and $data["email"] != $email_to) {
            $email_to = $data["email"];
            $email_subject = "Objednávka č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . " - " . def_value("default_firma", "hodnota") . "";
            if (!empty($status) and $status == "cp") {
                $email_subject = "Žiadosť o Cenovú ponuku pre objednávku č. " . $data_obj["c_obj"] . "/" . $data_obj["rok"] . " - " . def_value("default_firma", "hodnota") . "";
            }
            $headers = "From: \"" . def_value("default_firma", "hodnota") . "\" <" . def_value("default_email", "hodnota") . ">\r\n";
            $headers .= "Reply-To: " . def_value("default_email", "hodnota") . "\r\n";
            //$headers .= "CC: scooti@stonline.sk\r\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
            //mail($email_to, $email_subject, $message, $headers);
            $mail->clearAddresses();
            $mail->Subject = $email_subject;
            $mail->Body = $message;
            $mail->AddAddress($email_to);
            $mail->Send();
            //var_dump($email_to);
            //var_dump($data["email"]);
        }
    }
    echo "Email bol úspešne odoslaný na adresu: {$email_to}";
}
Example #26
0
 function sendmail()
 {
     global $CHARSET, $system;
     $this->errors = array();
     // from has not been set send email via admin
     if (!isset($this->from) || empty($this->from)) {
         $this->from = $system->SETTINGS['adminmail'];
     }
     // if sending to admin, send to all linked admin emails
     if ($system->SETTINGS['adminmail'] == $this->to) {
         $emails = array_filter(explode(',', $system->SETTINGS['alert_emails']));
         if (!empty($emails)) {
             if (!is_array($this->to)) {
                 $to_start = $this->to;
                 $this->to = array();
                 $this->to[] = $to_start;
             }
             foreach ($emails as $email) {
                 if (strlen($email) > 0 && preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $email)) {
                     $this->to[] = $email;
                 }
             }
         }
     }
     // deal with sending the emails
     switch ($system->SETTINGS['mail_protocol']) {
         case '5':
             $mail = new PHPMailer(true);
             $mail->isQmail();
             break;
         case '4':
             $mail = new PHPMailer(true);
             $mail->isSendmail();
             break;
         case '3':
             // do not send email
             return 'No email sent. You have selected to disable all emails';
             break;
         case '2':
             $mail = new PHPMailer(true);
             $mail->isSMTP();
             $mail->SMTPDebug = 0;
             $mail->Debugoutput = 'html';
             $mail->Host = $system->SETTINGS['smtp_host'];
             $mail->Port = (int) $system->SETTINGS['smtp_port'];
             if ($system->SETTINGS['smtp_security'] != 'none') {
                 $mail->SMTPSecure = strtolower($system->SETTINGS['smtp_security']);
             }
             if ($system->SETTINGS['smtp_authentication'] == 'y') {
                 $mail->SMTPAuth = true;
                 $mail->Username = $system->SETTINGS['smtp_username'];
                 $mail->Password = $system->SETTINGS['smtp_password'];
             } else {
                 $mail->SMTPAuth = false;
             }
             break;
         case '1':
             $mail = new PHPMailer(true);
             $mail->isMail();
             break;
         default:
             // just use php mail function
             if (is_array($this->to)) {
                 for ($i = 0; $i < count($this->to); $i++) {
                     if (!empty($system->SETTINGS['mail_parameter'])) {
                         $sent = mail($this->to[$i], $this->subject, $this->message, $this->headers, $system->SETTINGS['mail_parameter']);
                     } else {
                         $sent = mail($this->to[$i], $this->subject, $this->message, $this->headers);
                     }
                 }
             } else {
                 if (!empty($system->SETTINGS['mail_parameter'])) {
                     $sent = mail($this->to, $this->subject, $this->message, $this->headers, $system->SETTINGS['mail_parameter']);
                 } else {
                     $sent = mail($this->to, $this->subject, $this->message, $this->headers);
                 }
             }
             if ($sent) {
                 return false;
             } else {
                 return true;
             }
             break;
     }
     if (is_array($this->to)) {
         for ($i = 0; $i < count($this->to); $i++) {
             try {
                 $mail->setFrom($this->from, $system->SETTINGS['adminmail']);
                 $mail->addAddress($this->to[$i]);
                 $mail->addReplyTo($this->from, $system->SETTINGS['adminmail']);
                 $mail->Subject = $this->subject;
                 $mail->msgHTML($this->message);
                 //$mail->addAttachment('images/phpmailer_mini.png');
                 $mail->CharSet = $CHARSET;
                 $mail->Send();
             } catch (phpmailerException $e) {
                 trigger_error('---->PHPMailer error: ' . $e->errorMessage());
                 $this->add_error($e->errorMessage());
             } catch (Exception $e) {
                 trigger_error('---->PHPMailer error2: ' . $e->getMessage());
                 $this->add_error($e->getMessage());
             }
             $mail->clearAddresses();
         }
     } else {
         try {
             $mail->setFrom($this->from, $system->SETTINGS['adminmail']);
             if (is_array($this->to)) {
                 for ($i = 0; $i < count($this->to); $i++) {
                     $mail->addAddress($this->to[$i]);
                 }
             } else {
                 $mail->addAddress($this->to);
             }
             $mail->addReplyTo($this->from, $system->SETTINGS['adminmail']);
             $mail->Subject = $this->subject;
             $mail->msgHTML($this->message);
             $mail->CharSet = $CHARSET;
             $mail->Send();
         } catch (phpmailerException $e) {
             trigger_error('---->PHPMailer error: ' . $e->errorMessage());
             $this->add_error($e->errorMessage());
         } catch (Exception $e) {
             trigger_error('---->PHPMailer error: ' . $e->getMessage());
             $this->add_error($e->getMessage());
         }
     }
     return implode('<br/>', $this->errors);
 }
Example #27
-2
function phorum_smtp_send_messages($data)
{
    global $PHORUM;
    $addresses = $data['addresses'];
    $subject = $data['subject'];
    $message = $data['body'];
    $num_addresses = count($addresses);
    $settings = $PHORUM['smtp_mail'];
    $settings['auth'] = empty($settings['auth']) ? false : true;
    if ($num_addresses > 0) {
        try {
            require_once "./mods/smtp_mail/phpmailer/class.phpmailer.php";
            $mail = new PHPMailer();
            $mail->PluginDir = "./mods/smtp_mail/phpmailer/";
            $mail->CharSet = $PHORUM["DATA"]["CHARSET"];
            $mail->Encoding = $PHORUM["DATA"]["MAILENCODING"];
            $mail->Mailer = "smtp";
            $mail->isHTML(false);
            $mail->From = $PHORUM['system_email_from_address'];
            $mail->Sender = $PHORUM['system_email_from_address'];
            $mail->FromName = $PHORUM['system_email_from_name'];
            if (!isset($settings['host']) || empty($settings['host'])) {
                $settings['host'] = 'localhost';
            }
            if (!isset($settings['port']) || empty($settings['port'])) {
                $settings['port'] = '25';
            }
            $mail->Host = $settings['host'];
            $mail->Port = $settings['port'];
            // set the connection type
            if ($settings['conn'] == 'ssl') {
                $mail->SMTPSecure = "ssl";
            } elseif ($settings['conn'] == 'tls') {
                $mail->SMTPSecure = "tls";
            }
            // smtp-authentication
            if ($settings['auth'] && !empty($settings['username'])) {
                $mail->SMTPAuth = true;
                $mail->Username = $settings['username'];
                $mail->Password = $settings['password'];
            }
            $mail->Body = $message;
            $mail->Subject = $subject;
            // add the newly created message-id
            // in phpmailer as a public var
            $mail->MessageID = $data['messageid'];
            // add custom headers if defined
            if (!empty($data['custom_headers'])) {
                // custom headers in phpmailer are added one by one
                $custom_headers = explode("\n", $data['custom_headers']);
                foreach ($custom_headers as $cheader) {
                    $mail->addCustomHeader($cheader);
                }
            }
            // add attachments if provided
            if (isset($data['attachments']) && count($data['attachments'])) {
                /*
                 * Expected input is an array of
                 *
                 * array(
                 * 'filename'=>'name of the file including extension',
                 * 'filedata'=>'plain (not encoded) content of the file',
                 * 'mimetype'=>'mime type of the file', (optional)
                 * )
                 *
                 */
                foreach ($data['attachments'] as $att_id => $attachment) {
                    $att_type = !empty($attachment['mimetype']) ? $attachment['mimetype'] : 'application/octet-stream';
                    $mail->addStringAttachment($attachment['filedata'], $attachment['filename'], 'base64', $att_type);
                    // try to unset it in the original array to save memory
                    unset($data['attachments'][$att_id]);
                }
            }
            if (!empty($settings['bcc']) && $num_addresses > 3) {
                $bcc = 1;
                $mail->addAddress("undisclosed-recipients:;");
            } else {
                $bcc = 0;
                // lets keep the connection alive - it could be multiple mails
                $mail->SMTPKeepAlive = true;
            }
            foreach ($addresses as $address) {
                if ($bcc) {
                    $mail->addBCC($address);
                } else {
                    $mail->addAddress($address);
                    if (!$mail->send()) {
                        $error_msg = "There was an error sending the message.";
                        $detail_msg = "Error returned was: " . $mail->ErrorInfo;
                        if (function_exists('event_logging_writelog')) {
                            event_logging_writelog(array("source" => "smtp_mail", "message" => $error_msg, "details" => $detail_msg, "loglevel" => EVENTLOG_LVL_ERROR, "category" => EVENTLOG_CAT_MODULE));
                        }
                        if (!isset($settings['show_errors']) || !empty($settings['show_errors'])) {
                            echo $error_msg . "\n";
                            echo $detail_msg;
                        }
                    } elseif (!empty($settings['log_successful'])) {
                        if (function_exists('event_logging_writelog')) {
                            event_logging_writelog(array("source" => "smtp_mail", "message" => "Email successfully sent", "details" => "An email has been sent:\nTo:{$address}\nSubject: {$subject}\nBody: {$message}\n", "loglevel" => EVENTLOG_LVL_INFO, "category" => EVENTLOG_CAT_MODULE));
                        }
                    }
                    // Clear all addresses  for next loop
                    $mail->clearAddresses();
                }
            }
            // bcc needs just one send call
            if ($bcc) {
                if (!$mail->send()) {
                    $error_msg = "There was an error sending the bcc message.";
                    $detail_msg = "Error returned was: " . $mail->ErrorInfo;
                    if (function_exists('event_logging_writelog')) {
                        event_logging_writelog(array("source" => "smtp_mail", "message" => $error_msg, "details" => $detail_msg, "loglevel" => EVENTLOG_LVL_ERROR, "category" => EVENTLOG_CAT_MODULE));
                    }
                    if (!isset($settings['show_errors']) || !empty($settings['show_errors'])) {
                        echo $error_msg . "\n";
                        echo $detail_msg;
                    }
                } elseif (!empty($settings['log_successful'])) {
                    if (function_exists('event_logging_writelog')) {
                        $address_join = implode(",", $addresses);
                        event_logging_writelog(array("source" => "smtp_mail", "message" => "BCC-Email successfully sent", "details" => "An email (bcc-mode) has been sent:\nBCC:{$address_join}\nSubject: {$subject}\nBody: {$message}\n", "loglevel" => EVENTLOG_LVL_INFO, "category" => EVENTLOG_CAT_MODULE));
                    }
                }
            }
            // we have to close the connection with pipelining
            // which is only used in non-bcc mode
            if (!$bcc) {
                $mail->smtpClose();
            }
        } catch (Exception $e) {
            $error_msg = "There was a problem communicating with SMTP";
            $detail_msg = "The error returned was: " . $e->getMessage();
            if (function_exists('event_logging_writelog')) {
                event_logging_writelog(array("source" => "smtp_mail", "message" => $error_msg, "details" => $detail_msg, "loglevel" => EVENTLOG_LVL_ERROR, "category" => EVENTLOG_CAT_MODULE));
            }
            if (!isset($settings['show_errors']) || !empty($settings['show_errors'])) {
                echo $error_msg . "\n";
                echo $detail_msg;
            }
            exit;
        }
    }
    unset($message);
    unset($mail);
    // make sure that the internal mail-facility doesn't kick in
    return 0;
}