Перейти к содержанию
Официальный форум поддержки Simpla

Отправка писем через SMTP


Рекомендуемые сообщения

Мое решение, то чем пользуюсь сам в своих проектах.

 

https://github.com/kvalood/SimplaCMS-smtp

 

Если есть какие-нибудь замечания или предложения, пишите.

Ссылка на сообщение
Поделиться на другие сайты

Мое решение, то чем пользуюсь сам в своих проектах.

 

https://github.com/pulse-studio/SimplaCMS-smtp

Если есть какие-нибудь замечания или предложения, пишите.

Про композер мы не слышали?
Ссылка на сообщение
Поделиться на другие сайты

Про композер мы не слышали?

Слышали, да вот не все клиенты и участники форума про него слышали...

 

Завтра слегка переделаю инструкцию.

Ссылка на сообщение
Поделиться на другие сайты

Слышали, да вот не все клиенты и участники форума про него слышали...

 

Завтра слегка переделаю инструкцию.

Ничего страшного, пусть учатся новому, а то как Корс застынут в каменном веке :)
Ссылка на сообщение
Поделиться на другие сайты
  • 5 месяцев спустя...
  • 1 месяц спустя...

Насколько я понял, папку PHPMailer надо положить в корень, а не в папку api, как написано в инструкции.

Почитайте внимательно инструкцию на github.

 

"Находим папку src, копируем из неё все файлы к себе в проект, в папку /api/PHPmailer/ (папку PHPmailer надо создать)"

Ссылка на сообщение
Поделиться на другие сайты

Почитайте внимательно инструкцию на github.

 

"Находим папку src, копируем из неё все файлы к себе в проект, в папку /api/PHPmailer/ (папку PHPmailer надо создать)"

 

Ну так я же и говорю, что так неверно. Надо не в /api/PHPmailer/, а в /PHPmailer/ копировать файлы.

Ссылка на сообщение
Поделиться на другие сайты
В 12.05.2019 в 09:24, bananovsv сказал:

Ну так я же и говорю, что так неверно. Надо не в /api/PHPmailer/, а в /PHPmailer/ копировать файлы.

в папке /api/PHPmailer/

должны быть файлы https://github.com/kvalood/SimplaCMS-smtp/tree/master/api/PHPMailer

 

Что конкретно не верно? 

Что не работает?

Ссылка на сообщение
Поделиться на другие сайты
В 12.05.2019 в 09:35, ABSORBER сказал:

в папке /api/PHPmailer/

должны быть файлы https://github.com/kvalood/SimplaCMS-smtp/tree/master/api/PHPMailer

 

Что конкретно не верно? 

Что не работает?

 

Так пишет ошибку, что файлы не найдены. Если положить PHPmailer в корень, то всё работает.

Ссылка на сообщение
Поделиться на другие сайты

Так пишет ошибку, что файлы не найдены. Если положить PHPmailer в корень, то всё работает.

в notify.php

подключение такое?

 

require 'PHPMailer/Exception.php';

require 'PHPMailer/PHPMailer.php';

require 'PHPMailer/SMTP.php';

Ссылка на сообщение
Поделиться на другие сайты

в notify.php

подключение такое?

 

require 'PHPMailer/Exception.php';

require 'PHPMailer/PHPMailer.php';

require 'PHPMailer/SMTP.php';

 

Да, всё остальное по вашей инструкции.

Ссылка на сообщение
Поделиться на другие сайты

в 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
Изменено пользователем bananovsv
Ссылка на сообщение
Поделиться на другие сайты

всё равно не пашет! 
сделал всё по инструкции! 
отчёт файла _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

Ссылка на сообщение
Поделиться на другие сайты

всё равно не пашет! 

сделал всё по инструкции! 

отчёт файла _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

Напишите мне в ЛС. Контакты ниже или в профиле.

Ссылка на сообщение
Поделиться на другие сайты
  • 5 месяцев спустя...

Толку нету , не работает !

Так и остался вопрос открытым

Все работает.

Пишите в ЛС, контакты в профиле

Ссылка на сообщение
Поделиться на другие сайты

Подскажите где ошибся в 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>");
	}


}
Ссылка на сообщение
Поделиться на другие сайты
    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);
    }

Поменяйте местами 

Ссылка на сообщение
Поделиться на другие сайты

току нет - при отправке ползунок крутится на странице долго долго и страница выключается 504 Gateway Time-out но письмо доходит спустя 20-30 мин

Ссылка на сообщение
Поделиться на другие сайты
  • 2 месяца спустя...

Тоже не работает, ошибка 

Parse error: syntax error, unexpected '[' in /var/www/cdlcpto16605/data/www/site.ru/api/Notify.php on line 60

Видимо версия php ниже 5.6

Ссылка на сообщение
Поделиться на другие сайты
  • 2 месяца спустя...

Не работает. 


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

Ссылка на сообщение
Поделиться на другие сайты

Не работает. 

 

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

 

 

у вас какие то проблемы с базой данных нет подключение. модуль тут вообще не причем.

Ссылка на сообщение
Поделиться на другие сайты

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Вставить как обычный текст

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

Загрузка...
×
×
  • Создать...