ABSORBER Posted October 17, 2018 Report Share Posted October 17, 2018 Мое решение, то чем пользуюсь сам в своих проектах. https://github.com/kvalood/SimplaCMS-smtp Если есть какие-нибудь замечания или предложения, пишите. Quote Link to post Share on other sites
Noxter Posted October 17, 2018 Report Share Posted October 17, 2018 Мое решение, то чем пользуюсь сам в своих проектах. https://github.com/pulse-studio/SimplaCMS-smtpЕсли есть какие-нибудь замечания или предложения, пишите.Про композер мы не слышали? Quote Link to post Share on other sites
ABSORBER Posted October 17, 2018 Author Report Share Posted October 17, 2018 Про композер мы не слышали?Слышали, да вот не все клиенты и участники форума про него слышали... Завтра слегка переделаю инструкцию. Quote Link to post Share on other sites
Noxter Posted October 17, 2018 Report Share Posted October 17, 2018 Слышали, да вот не все клиенты и участники форума про него слышали... Завтра слегка переделаю инструкцию.Ничего страшного, пусть учатся новому, а то как Корс застынут в каменном веке Quote Link to post Share on other sites
ABSORBER Posted March 28, 2019 Author Report Share Posted March 28, 2019 UPD: Добавил описание опций в config.php Quote Link to post Share on other sites
bananovsv Posted May 11, 2019 Report Share Posted May 11, 2019 Насколько я понял, папку PHPMailer надо положить в корень, а не в папку api, как написано в инструкции. Quote Link to post Share on other sites
ABSORBER Posted May 11, 2019 Author Report Share Posted May 11, 2019 Насколько я понял, папку PHPMailer надо положить в корень, а не в папку api, как написано в инструкции.Почитайте внимательно инструкцию на github. "Находим папку src, копируем из неё все файлы к себе в проект, в папку /api/PHPmailer/ (папку PHPmailer надо создать)" Quote Link to post Share on other sites
bananovsv Posted May 11, 2019 Report Share Posted May 11, 2019 Почитайте внимательно инструкцию на github. "Находим папку src, копируем из неё все файлы к себе в проект, в папку /api/PHPmailer/ (папку PHPmailer надо создать)" Ну так я же и говорю, что так неверно. Надо не в /api/PHPmailer/, а в /PHPmailer/ копировать файлы. Quote Link to post Share on other sites
ABSORBER Posted May 11, 2019 Author Report Share Posted May 11, 2019 В 12.05.2019 в 09:24, bananovsv сказал: Ну так я же и говорю, что так неверно. Надо не в /api/PHPmailer/, а в /PHPmailer/ копировать файлы. в папке /api/PHPmailer/ должны быть файлы https://github.com/kvalood/SimplaCMS-smtp/tree/master/api/PHPMailer Что конкретно не верно? Что не работает? Quote Link to post Share on other sites
bananovsv Posted May 11, 2019 Report Share Posted May 11, 2019 В 12.05.2019 в 09:35, ABSORBER сказал: в папке /api/PHPmailer/ должны быть файлы https://github.com/kvalood/SimplaCMS-smtp/tree/master/api/PHPMailer Что конкретно не верно? Что не работает? Так пишет ошибку, что файлы не найдены. Если положить PHPmailer в корень, то всё работает. Quote Link to post Share on other sites
ABSORBER Posted May 12, 2019 Author Report Share Posted May 12, 2019 Так пишет ошибку, что файлы не найдены. Если положить PHPmailer в корень, то всё работает.в notify.phpподключение такое? require 'PHPMailer/Exception.php';require 'PHPMailer/PHPMailer.php';require 'PHPMailer/SMTP.php'; Quote Link to post Share on other sites
bananovsv Posted May 12, 2019 Report Share Posted May 12, 2019 в notify.phpподключение такое? require 'PHPMailer/Exception.php';require 'PHPMailer/PHPMailer.php';require 'PHPMailer/SMTP.php'; Да, всё остальное по вашей инструкции. Quote Link to post Share on other sites
bananovsv Posted May 12, 2019 Report Share Posted May 12, 2019 (edited) в notify.phpподключение такое? require 'PHPMailer/Exception.php';require 'PHPMailer/PHPMailer.php';require 'PHPMailer/SMTP.php'; Может быть это только у меня, я не настаиваю. Но если папку положить в api, то будет так: PHP Warning: require(PHPMailer/Exception.php): failed to open stream: No such file or directory in /…/public_html/api/Notify.php on line 15 Edited May 12, 2019 by bananovsv Quote Link to post Share on other sites
mdmatic Posted May 13, 2019 Report Share Posted May 13, 2019 всё равно не пашет! сделал всё по инструкции! отчёт файла _test_mail.php Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /cut/public_html/api/Database.php on line 47 2019-05-10 08:12:30 Connection: opening to veles.shop:587, timeout=300, options=array ( 'ssl' => array ( 'verify_peer' => true, 'verify_peer_name' => true, 'allow_self_signed' => true, ),) 2019-05-10 08:13:10 Connection failed. Error #2: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known [/cut/public_html/api/PHPMailer/SMTP.php line 327] 2019-05-10 08:13:10 Connection failed. Error #2: stream_socket_client(): unable to connect to veles.shop:587 (php_network_getaddresses: getaddrinfo failed: Name or service not known) [/cut/public_html/api/PHPMailer/SMTP.php line 327] 2019-05-10 08:13:10 SMTP ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Name or service not known (0) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting я так подозреваю, проблема в использовании TLS Quote Link to post Share on other sites
ABSORBER Posted May 13, 2019 Author Report Share Posted May 13, 2019 всё равно не пашет! сделал всё по инструкции! отчёт файла _test_mail.php Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /cut/public_html/api/Database.php on line 47 2019-05-10 08:12:30 Connection: opening to veles.shop:587, timeout=300, options=array ( 'ssl' => array ( 'verify_peer' => true, 'verify_peer_name' => true, 'allow_self_signed' => true, ),) 2019-05-10 08:13:10 Connection failed. Error #2: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known [/cut/public_html/api/PHPMailer/SMTP.php line 327] 2019-05-10 08:13:10 Connection failed. Error #2: stream_socket_client(): unable to connect to veles.shop:587 (php_network_getaddresses: getaddrinfo failed: Name or service not known) [/cut/public_html/api/PHPMailer/SMTP.php line 327] 2019-05-10 08:13:10 SMTP ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Name or service not known (0) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting я так подозреваю, проблема в использовании TLSНапишите мне в ЛС. Контакты ниже или в профиле. Quote Link to post Share on other sites
vcontakte Posted October 21, 2019 Report Share Posted October 21, 2019 Толку нету , не работает !Так и остался вопрос открытым Quote Link to post Share on other sites
ABSORBER Posted October 21, 2019 Author Report Share Posted October 21, 2019 Толку нету , не работает !Так и остался вопрос открытымВсе работает.Пишите в ЛС, контакты в профиле Quote Link to post Share on other sites
vcontakte Posted October 23, 2019 Report Share Posted October 23, 2019 Подскажите где ошибся в api/Notify.php не могу понять что не так . <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'PHPMailer/Exception.php'; require 'PHPMailer/PHPMailer.php'; require 'PHPMailer/SMTP.php'; class Notify extends Simpla { public $SMTPDebug = 0; function php_email($to, $subject, $message, $from = '', $reply_to = '') { $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=utf-8; \r\n"; $headers .= "From: " . $this->settings->company_name . "<$from> \r\n"; if (!empty($reply_to)) $headers .= "reply-to: $reply_to\r\n"; $subject = "=?utf-8?B?" . base64_encode($subject) . "?="; @mail($to, $subject, $message, $headers); } function email($to, $subject, $message, $from = '', $reply_to = '') { if (!$this->config->phpmailer_enable) { $this->php_mail($to, $subject, $message, $from, $reply_to); } else { $mailer = new Phpmailer(); $mailer->IsHTML(true); $mailer->CharSet = "utf-8"; $mailer->IsSMTP(); $mailer->Host = $this->config->phpmailer_host; $mailer->Port = $this->config->phpmailer_port; if ($this->config->phpmailer_ssl == true) { $mailer->SMTPSecure = "ssl"; $mailer->SMTPAutoTLS = "false"; // Отключить проверку сертификата - https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#updating-ca-certificates if ($this->config->phpmailer_ssl_verify != true) { $mailer->SMTPOptions = [ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ] ]; } } $mailer->SMTPAuth = true; $mailer->Username = $this->config->phpmailer_user; $mailer->Password = $this->config->phpmailer_password; foreach(preg_split('/[\s,;]+/', $to) as $e) { $mailer->AddAddress($e); } $mailer->From = $mailer->Username; // $from $mailer->FromName = $this->settings->company_name; $mailer->Sender = $mailer->Username; $mailer->Subject = $subject; $mailer->Body = $message; $mailer->SMTPDebug = $this->SMTPDebug; // 3 if (!$mailer->Send()) { if ($this->SMTPDebug) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mailer->ErrorInfo; } $this->php_email($to, $subject, $message, $mailer->From); } } } public function email_order_user($order_id) { if(!($order = $this->orders->get_order(intval($order_id))) || empty($order->email)) return false; $purchases = $this->orders->get_purchases(array('order_id'=>$order->id)); $this->design->assign('purchases', $purchases); $products_ids = array(); $variants_ids = array(); foreach($purchases as $purchase) { $products_ids[] = $purchase->product_id; $variants_ids[] = $purchase->variant_id; } $products = array(); foreach($this->products->get_products(array('id'=>$products_ids)) as $p) $products[$p->id] = $p; $images = $this->products->get_images(array('product_id'=>$products_ids)); foreach($images as $image) $products[$image->product_id]->images[] = $image; $variants = array(); foreach($this->variants->get_variants(array('id'=>$variants_ids)) as $v) { $variants[$v->id] = $v; $products[$v->product_id]->variants[] = $v; } foreach($purchases as &$purchase) { if(!empty($products[$purchase->product_id])) $purchase->product = $products[$purchase->product_id]; if(!empty($variants[$purchase->variant_id])) $purchase->variant = $variants[$purchase->variant_id]; } // Способ доставки $delivery = $this->delivery->get_delivery($order->delivery_id); $this->design->assign('delivery', $delivery); $this->design->assign('order', $order); $this->design->assign('purchases', $purchases); // Отправляем письмо // Если в шаблон не передавалась валюта, передадим if ($this->design->smarty->getTemplateVars('currency') === null) { $this->design->assign('currency', current($this->money->get_currencies(array('enabled'=>1)))); } $email_template = $this->design->fetch($this->config->root_dir.'design/'.$this->settings->theme.'/html/email_order.tpl'); $subject = $this->design->get_var('subject'); $this->email($order->email, $subject, $email_template, $this->settings->notify_from_email); } public function email_order_admin($order_id) { if(!($order = $this->orders->get_order(intval($order_id)))) return false; $purchases = $this->orders->get_purchases(array('order_id'=>$order->id)); $this->design->assign('purchases', $purchases); $products_ids = array(); $variants_ids = array(); foreach($purchases as $purchase) { $products_ids[] = $purchase->product_id; $variants_ids[] = $purchase->variant_id; } $products = array(); foreach($this->products->get_products(array('id'=>$products_ids)) as $p) $products[$p->id] = $p; $images = $this->products->get_images(array('product_id'=>$products_ids)); foreach($images as $image) $products[$image->product_id]->images[] = $image; $variants = array(); foreach($this->variants->get_variants(array('id'=>$variants_ids)) as $v) { $variants[$v->id] = $v; $products[$v->product_id]->variants[] = $v; } foreach($purchases as &$purchase) { if(!empty($products[$purchase->product_id])) $purchase->product = $products[$purchase->product_id]; if(!empty($variants[$purchase->variant_id])) $purchase->variant = $variants[$purchase->variant_id]; } // Способ доставки $delivery = $this->delivery->get_delivery($order->delivery_id); $this->design->assign('delivery', $delivery); // Пользователь $user = $this->users->get_user(intval($order->user_id)); $this->design->assign('user', $user); $this->design->assign('order', $order); $this->design->assign('purchases', $purchases); // В основной валюте $this->design->assign('main_currency', $this->money->get_currency()); // Отправляем письмо $email_template = $this->design->fetch($this->config->root_dir.'simpla/design/html/email_order_admin.tpl'); $subject = $this->design->get_var('subject'); $this->email($this->settings->order_email, $subject, $email_template, $this->settings->notify_from_email); } public function email_comment_admin($comment_id) { if(!($comment = $this->comments->get_comment(intval($comment_id)))) return false; if($comment->type == 'product') $comment->product = $this->products->get_product(intval($comment->object_id)); if($comment->type == 'blog') $comment->post = $this->blog->get_post(intval($comment->object_id)); $this->design->assign('comment', $comment); // Отправляем письмо $email_template = $this->design->fetch($this->config->root_dir.'simpla/design/html/email_comment_admin.tpl'); $subject = $this->design->get_var('subject'); $this->email($this->settings->comment_email, $subject, $email_template, $this->settings->notify_from_email); } public function email_password_remind($user_id, $code) { if(!($user = $this->users->get_user(intval($user_id)))) return false; $this->design->assign('user', $user); $this->design->assign('code', $code); // Отправляем письмо $email_template = $this->design->fetch($this->config->root_dir.'design/'.$this->settings->theme.'/html/email_password_remind.tpl'); $subject = $this->design->get_var('subject'); $this->email($user->email, $subject, $email_template, $this->settings->notify_from_email); $this->design->smarty->clearAssign('user'); $this->design->smarty->clearAssign('code'); } public function email_feedback_admin($feedback_id) { if(!($feedback = $this->feedbacks->get_feedback(intval($feedback_id)))) return false; $this->design->assign('feedback', $feedback); // Отправляем письмо $email_template = $this->design->fetch($this->config->root_dir.'simpla/design/html/email_feedback_admin.tpl'); $subject = $this->design->get_var('subject'); $this->email($this->settings->comment_email, $subject, $email_template, "$feedback->name <$feedback->email>", "$feedback->name <$feedback->email>"); } } Quote Link to post Share on other sites
alexivchenko Posted October 23, 2019 Report Share Posted October 23, 2019 function email($to, $subject, $message, $from = '', $reply_to = '') { if (!$this->config->phpmailer_enable) { $this->php_mail($to, $subject, $message, $from, $reply_to); } else { $mailer = new Phpmailer(); $mailer->IsHTML(true); $mailer->CharSet = "utf-8"; $mailer->IsSMTP(); $mailer->Host = $this->config->phpmailer_host; $mailer->Port = $this->config->phpmailer_port; if ($this->config->phpmailer_ssl == true) { $mailer->SMTPSecure = "ssl"; $mailer->SMTPAutoTLS = "false"; // Отключить проверку сертификата - https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#updating-ca-certificates if ($this->config->phpmailer_ssl_verify != true) { $mailer->SMTPOptions = [ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ] ]; } } $mailer->SMTPAuth = true; $mailer->Username = $this->config->phpmailer_user; $mailer->Password = $this->config->phpmailer_password; foreach(preg_split('/[\s,;]+/', $to) as $e) { $mailer->AddAddress($e); } $mailer->From = $mailer->Username; // $from $mailer->FromName = $this->settings->company_name; $mailer->Sender = $mailer->Username; $mailer->Subject = $subject; $mailer->Body = $message; $mailer->SMTPDebug = $this->SMTPDebug; // 3 if (!$mailer->Send()) { if ($this->SMTPDebug) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mailer->ErrorInfo; } $this->php_email($to, $subject, $message, $mailer->From); } } } function php_email($to, $subject, $message, $from = '', $reply_to = '') { $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=utf-8; \r\n"; $headers .= "From: " . $this->settings->company_name . "<$from> \r\n"; if (!empty($reply_to)) $headers .= "reply-to: $reply_to\r\n"; $subject = "=?utf-8?B?" . base64_encode($subject) . "?="; @mail($to, $subject, $message, $headers); } Поменяйте местами Quote Link to post Share on other sites
vcontakte Posted October 23, 2019 Report Share Posted October 23, 2019 току нет - при отправке ползунок крутится на странице долго долго и страница выключается 504 Gateway Time-out но письмо доходит спустя 20-30 мин Quote Link to post Share on other sites
Axotn1k Posted January 9, 2020 Report Share Posted January 9, 2020 Тоже не работает, ошибка Parse error: syntax error, unexpected '[' in /var/www/cdlcpto16605/data/www/site.ru/api/Notify.php on line 60 Quote Link to post Share on other sites
ABSORBER Posted January 9, 2020 Author Report Share Posted January 9, 2020 Тоже не работает, ошибка Parse error: syntax error, unexpected '[' in /var/www/cdlcpto16605/data/www/site.ru/api/Notify.php on line 60Видимо версия php ниже 5.6 Quote Link to post Share on other sites
Axotn1k Posted January 10, 2020 Report Share Posted January 10, 2020 Модуль работает отлично, изменил версию на 5.6, спасибо большое! Quote Link to post Share on other sites
OneMind Posted April 7, 2020 Report Share Posted April 7, 2020 Не работает. Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /home/bahiloff/public_html/api/Database.php on line 46Warning: Could not connect to the database: Access denied for user 'root'@'localhost' (using password: NO) in /home/bahiloff/public_html/api/Database.php on line 51Warning: mysqli::query(): Couldn't fetch mysqli in /home/bahiloff/public_html/api/Database.php on line 90Warning: Database::results(): Couldn't fetch mysqli in /home/bahiloff/public_html/api/Database.php on line 136Warning: in /home/bahiloff/public_html/api/Database.php on line 136Warning: Invalid argument supplied for foreach() in /home/bahiloff/public_html/api/Settings.php on line 28 Quote Link to post Share on other sites
shooroop Posted April 7, 2020 Report Share Posted April 7, 2020 Не работает. Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /home/bahiloff/public_html/api/Database.php on line 46 Warning: Could not connect to the database: Access denied for user 'root'@'localhost' (using password: NO) in /home/bahiloff/public_html/api/Database.php on line 51 Warning: mysqli::query(): Couldn't fetch mysqli in /home/bahiloff/public_html/api/Database.php on line 90 Warning: Database::results(): Couldn't fetch mysqli in /home/bahiloff/public_html/api/Database.php on line 136 Warning: in /home/bahiloff/public_html/api/Database.php on line 136 Warning: Invalid argument supplied for foreach() in /home/bahiloff/public_html/api/Settings.php on line 28 у вас какие то проблемы с базой данных нет подключение. модуль тут вообще не причем. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.