Перейти до вмісту
Пошук в
  • Детальніше...
Шукати результати, які ...
Шукати результати в ...

Настройка SMTP (yandex.ru)


Rashpil

Recommended Posts

  • 1 month later...
  • 1 month later...

К сожалению, НЕ работает на версии 1.5.5.1.2 (ocStore). 

2015-01-22 11:17:11 - PHP Warning:  fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/vhosts/my-domain-name.ru.plsk.regruhosting.ru/my-domain-name.ru/www/system/library/mail.php on line 153
2015-01-22 11:17:11 - PHP Warning:  fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to  ssl://smtp.yandex.ru :465 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /var/www/vhosts/my-account.plsk.regruhosting.ru/my-domain-name.ru/www/system/library/mail.php on line 153
2015-01-22 11:17:11 - PHP Notice:  Error: php_network_getaddresses: getaddrinfo failed: Name or service not known (0) in /var/www/vhosts/my-account.plsk.regruhosting.ru/my-domain-name.ru/www/system/library/mail.php on line 156

методом тыка было определенно что проблема именно в строке 

ssl://

если убрать то, идет попытка отправки, после чего ответ с ошибкой от сервера Яндекс

Error: EHLO not accepted from server! in /var/www/vhosts/my-account.plsk.regruhosting.ru/new.systems-it.ru/www/system/library/mail.php on line 200

Может у кого есть какие мысли?!

Надіслати
Поділитися на інших сайтах


  • 6 months later...

Подскажите пожалуйста как побороть ошибку?

PHP Notice:  Error: DATA not accepted from server! in /var/www/jeelex/system/library/mail.php on line 380

Причём письма о новом заказе через модуль быстрого заказа по smtp yandex приходят а через корзину нет и в логах Error: DATA not accepted from server! как исправить? 

Надіслати
Поділитися на інших сайтах


Заменил mail.php на этот и всё работает даже обратная связь на сайте
 

<?php
final class Mail {
    protected $to;
    protected $from;
    protected $sender;
    protected $subject;
    protected $text;
    protected $html;
    protected $attachments = array();
    public $protocol = 'mail';
    public $hostname;
    public $username;
    public $password;
    public $port = 25;
    public $timeout = 5;
    public $newline = "\r\n";
    public $crlf = "\r\n";
    public $verp = FALSE;
    public $parameter = '';

    public function setTo($to) {
        $this->to = $to;
    }

    public function setFrom($from) {
        $this->from = $from;
    }

    public function addheader($header, $value) {
        $this->headers[$header] = $value;
    }

    public function setSender($sender) {
        $this->sender = html_entity_decode($sender);
    }

public function setSubject($subject) {
$this->subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
}

    public function setText($text) {
        $this->text = $text;

    }

    public function setHtml($html) {
        $this->html = $html;
    }

    public function addAttachment($file, $filename = '') {
        if (!$filename) {
            $filename = basename($file);
        }

        $this->attachments[] = array(
            'filename' => $filename,
            'file' => $file
        );
    }

    public function send() {
        if (!$this->to) {
            exit('Error: E-Mail to required!');
        }

        if (!$this->from) {
            exit('Error: E-Mail from required!');
        }

        if (!$this->sender) {
            exit('Error: E-Mail sender required!');
        }

        if (!$this->subject) {
            exit('Error: E-Mail subject required!');
        }

        if ((!$this->text) && (!$this->html)) {
            exit('Error: E-Mail message required!');
        }

        if (is_array($this->to)) {
            $to = implode(',', $this->to);
        } else {
            $to = $this->to;
        }

        $boundary = '----=_NextPart_' . md5(time());

        $header = '';

        if ($this->protocol != 'mail') {
            $header .= 'To: ' . $to . $this->newline;
            $header .= 'Subject: ' . $this->subject . $this->newline;
        }

        $header .= 'Date: ' . date("D, d M Y H:i:s O") . $this->newline;
        //$header .= 'From: "' . $this->sender . '" <' . $this->from . '>' . $this->newline;
        //$header .= 'From: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
        $header .= 'From: ' . '=?UTF-8?B?'.base64_encode($this->sender).'?=' . '<' . $this->from . '>' . $this->newline;
        $header .= 'Reply-To: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
        $header .= 'Return-Path: ' . $this->from . $this->newline;
        $header .= 'X-Mailer: PHP/' . phpversion() . $this->newline;
        $header .= 'MIME-Version: 1.0' . $this->newline;
        $header .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $this->newline;
        $header .= 'Content-Transfer-Encoding: 8bit' . $this->newline;        
        $header .= $this->newline;

        if (!$this->html) {
            $message = '--' . $boundary . $this->newline;
            $message .= 'Content-Type: text/plain; charset="utf-8"' . $this->newline;
            $message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;
            $message .= $this->text . $this->newline;
        } else {
            $message = '--' . $boundary . $this->newline;
            $message .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '_alt"' . $this->newline . $this->newline;
            $message .= '--' . $boundary . '_alt' . $this->newline;
            $message .= '' . $this->newline;
            $message .= '' . $this->newline;

            if ($this->text) {
                $message .= $this->text . $this->newline;
            } else {
                $message .= '' . $this->newline;
            }

            $message .= '--' . $boundary . '_alt' . $this->newline;
            $message .= 'Content-Type: text/html; charset="utf-8"' . $this->newline;
            $message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;
            $message .= $this->html . $this->newline;
            $message .= '--' . $boundary . '_alt--' . $this->newline;
        }

foreach ($this->attachments as $attachment) {
if (file_exists($attachment['file'])) {
$handle = fopen($attachment['file'], 'r');
$content = fread($handle, filesize($attachment['file']));

fclose($handle);

$message .= '--' . $boundary . $this->newline;
$message .= 'Content-Type: application/octetstream' . $this->newline;
$message .= 'Content-Transfer-Encoding: base64' . $this->newline;
$message .= 'Content-Disposition: attachment; filename="' . basename($attachment['filename']) . '"' . $this->newline;
$message .= 'Content-ID: <' . basename($attachment['filename']) . '>' . $this->newline . $this->newline;
$message .= chunk_split(base64_encode($content));
}
}

        $message .= '--' . $boundary . '--' . $this->newline;

        if ($this->protocol == 'mail') {
            ini_set('sendmail_from', $this->from);

            if ($this->parameter) {
                mail($to, '=?UTF-8?B?'.base64_encode($this->subject).'?=', $message, $header, $this->parameter);
            } else {
                mail($to, '=?UTF-8?B?'.base64_encode($this->subject).'?=', $message, $header);
            }

        } elseif ($this->protocol == 'smtp') {
            $handle = fsockopen($this->hostname, $this->port, $errno, $errstr, $this->timeout);

            if (!$handle) {
                error_log('Error: ' . $errstr . ' (' . $errno . ')');
            } else {
                if (substr(PHP_OS, 0, 3) != 'WIN') {
                    socket_set_timeout($handle, $this->timeout, 0);
                }

                while ($line = fgets($handle, 515)) {
                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($this->hostname, 0, 3) == 'tls') {
                    fputs($handle, 'STARTTLS' . $this->crlf);

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 220) {
                        error_log('Error: STARTTLS not accepted from server!');
                    }
                }

                if (!empty($this->username) && !empty($this->password)) {
                    fputs($handle, 'EHLO ' . getenv('SERVER_NAME') . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 250) {
                        error_log('Error: EHLO not accepted from server!');
                    }

                    fputs($handle, 'AUTH LOGIN' . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 334) {
                        error_log('Error: AUTH LOGIN not accepted from server!');
                    }

                    fputs($handle, base64_encode($this->username) . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 334) {
                        error_log('Error: Username not accepted from server!');
                    }

                    fputs($handle, base64_encode($this->password) . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 235) {
                        error_log('Error: Password not accepted from server!');
                    }
                } else {
                    fputs($handle, 'HELO ' . getenv('SERVER_NAME') . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 250) {
                        error_log('Error: HELO not accepted from server!');
                    }
                }

                if ($this->verp) {
                    fputs($handle, 'MAIL FROM: <' . $this->username . '>XVERP' . $this->crlf);
                } else {
                    fputs($handle, 'MAIL FROM: <' . $this->username . '>' . $this->crlf);
                }

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 250) {
                    error_log('Error: MAIL FROM not accepted from server!');
                }

                if (!is_array($this->to)) {
                    fputs($handle, 'RCPT TO: <' . $this->to . '>' . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if ((substr($reply, 0, 3) != 250) && (substr($reply, 0, 3) != 251)) {
                        error_log('Error: RCPT TO not accepted from server!');
                    }
                } else {
                    foreach ($this->to as $recipient) {
                        fputs($handle, 'RCPT TO: <' . $recipient . '>' . $this->crlf);

                        $reply = '';

                        while ($line = fgets($handle, 515)) {
                            $reply .= $line;

                            if (substr($line, 3, 1) == ' ') {
                                break;
                            }
                        }

                        if ((substr($reply, 0, 3) != 250) && (substr($reply, 0, 3) != 251)) {
                            error_log('Error: RCPT TO not accepted from server!');
                        }
                    }
                }

                fputs($handle, 'DATA' . $this->crlf);

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 354) {
                    error_log('Error: DATA not accepted from server!');
                }

                fputs($handle, $header . $message . $this->crlf);
                fputs($handle, '.' . $this->crlf);

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 250) {
                    error_log('Error: DATA not accepted from server!');
                }

                fputs($handle, 'QUIT' . $this->crlf);

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 221) {
                    error_log('Error: QUIT not accepted from server!');
                }

                fclose($handle);
            }
        }
    }
}
?>
Надіслати
Поділитися на інших сайтах


  • 3 weeks later...

 

Заменил mail.php на этот и всё работает даже обратная связь на сайте

 

<?php
final class Mail {
    protected $to;
    protected $from;
    protected $sender;
    protected $subject;
    protected $text;
    protected $html;
    protected $attachments = array();
    public $protocol = 'mail';
    public $hostname;
    public $username;
    public $password;
    public $port = 25;
    public $timeout = 5;
    public $newline = "\r\n";
    public $crlf = "\r\n";
    public $verp = FALSE;
    public $parameter = '';

    public function setTo($to) {
        $this->to = $to;
    }

    public function setFrom($from) {
        $this->from = $from;
    }

    public function addheader($header, $value) {
        $this->headers[$header] = $value;
    }

    public function setSender($sender) {
        $this->sender = html_entity_decode($sender);
    }

public function setSubject($subject) {
$this->subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
}

    public function setText($text) {
        $this->text = $text;

    }

    public function setHtml($html) {
        $this->html = $html;
    }

    public function addAttachment($file, $filename = '') {
        if (!$filename) {
            $filename = basename($file);
        }

        $this->attachments[] = array(
            'filename' => $filename,
            'file' => $file
        );
    }

    public function send() {
        if (!$this->to) {
            exit('Error: E-Mail to required!');
        }

        if (!$this->from) {
            exit('Error: E-Mail from required!');
        }

        if (!$this->sender) {
            exit('Error: E-Mail sender required!');
        }

        if (!$this->subject) {
            exit('Error: E-Mail subject required!');
        }

        if ((!$this->text) && (!$this->html)) {
            exit('Error: E-Mail message required!');
        }

        if (is_array($this->to)) {
            $to = implode(',', $this->to);
        } else {
            $to = $this->to;
        }

        $boundary = '----=_NextPart_' . md5(time());

        $header = '';

        if ($this->protocol != 'mail') {
            $header .= 'To: ' . $to . $this->newline;
            $header .= 'Subject: ' . $this->subject . $this->newline;
        }

        $header .= 'Date: ' . date("D, d M Y H:i:s O") . $this->newline;
        //$header .= 'From: "' . $this->sender . '" <' . $this->from . '>' . $this->newline;
        //$header .= 'From: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
        $header .= 'From: ' . '=?UTF-8?B?'.base64_encode($this->sender).'?=' . '<' . $this->from . '>' . $this->newline;
        $header .= 'Reply-To: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
        $header .= 'Return-Path: ' . $this->from . $this->newline;
        $header .= 'X-Mailer: PHP/' . phpversion() . $this->newline;
        $header .= 'MIME-Version: 1.0' . $this->newline;
        $header .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $this->newline;
        $header .= 'Content-Transfer-Encoding: 8bit' . $this->newline;        
        $header .= $this->newline;

        if (!$this->html) {
            $message = '--' . $boundary . $this->newline;
            $message .= 'Content-Type: text/plain; charset="utf-8"' . $this->newline;
            $message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;
            $message .= $this->text . $this->newline;
        } else {
            $message = '--' . $boundary . $this->newline;
            $message .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '_alt"' . $this->newline . $this->newline;
            $message .= '--' . $boundary . '_alt' . $this->newline;
            $message .= '' . $this->newline;
            $message .= '' . $this->newline;

            if ($this->text) {
                $message .= $this->text . $this->newline;
            } else {
                $message .= '' . $this->newline;
            }

            $message .= '--' . $boundary . '_alt' . $this->newline;
            $message .= 'Content-Type: text/html; charset="utf-8"' . $this->newline;
            $message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;
            $message .= $this->html . $this->newline;
            $message .= '--' . $boundary . '_alt--' . $this->newline;
        }

foreach ($this->attachments as $attachment) {
if (file_exists($attachment['file'])) {
$handle = fopen($attachment['file'], 'r');
$content = fread($handle, filesize($attachment['file']));

fclose($handle);

$message .= '--' . $boundary . $this->newline;
$message .= 'Content-Type: application/octetstream' . $this->newline;
$message .= 'Content-Transfer-Encoding: base64' . $this->newline;
$message .= 'Content-Disposition: attachment; filename="' . basename($attachment['filename']) . '"' . $this->newline;
$message .= 'Content-ID: <' . basename($attachment['filename']) . '>' . $this->newline . $this->newline;
$message .= chunk_split(base64_encode($content));
}
}

        $message .= '--' . $boundary . '--' . $this->newline;

        if ($this->protocol == 'mail') {
            ini_set('sendmail_from', $this->from);

            if ($this->parameter) {
                mail($to, '=?UTF-8?B?'.base64_encode($this->subject).'?=', $message, $header, $this->parameter);
            } else {
                mail($to, '=?UTF-8?B?'.base64_encode($this->subject).'?=', $message, $header);
            }

        } elseif ($this->protocol == 'smtp') {
            $handle = fsockopen($this->hostname, $this->port, $errno, $errstr, $this->timeout);

            if (!$handle) {
                error_log('Error: ' . $errstr . ' (' . $errno . ')');
            } else {
                if (substr(PHP_OS, 0, 3) != 'WIN') {
                    socket_set_timeout($handle, $this->timeout, 0);
                }

                while ($line = fgets($handle, 515)) {
                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($this->hostname, 0, 3) == 'tls') {
                    fputs($handle, 'STARTTLS' . $this->crlf);

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 220) {
                        error_log('Error: STARTTLS not accepted from server!');
                    }
                }

                if (!empty($this->username) && !empty($this->password)) {
                    fputs($handle, 'EHLO ' . getenv('SERVER_NAME') . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 250) {
                        error_log('Error: EHLO not accepted from server!');
                    }

                    fputs($handle, 'AUTH LOGIN' . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 334) {
                        error_log('Error: AUTH LOGIN not accepted from server!');
                    }

                    fputs($handle, base64_encode($this->username) . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 334) {
                        error_log('Error: Username not accepted from server!');
                    }

                    fputs($handle, base64_encode($this->password) . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 235) {
                        error_log('Error: Password not accepted from server!');
                    }
                } else {
                    fputs($handle, 'HELO ' . getenv('SERVER_NAME') . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 250) {
                        error_log('Error: HELO not accepted from server!');
                    }
                }

                if ($this->verp) {
                    fputs($handle, 'MAIL FROM: <' . $this->username . '>XVERP' . $this->crlf);
                } else {
                    fputs($handle, 'MAIL FROM: <' . $this->username . '>' . $this->crlf);
                }

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 250) {
                    error_log('Error: MAIL FROM not accepted from server!');
                }

                if (!is_array($this->to)) {
                    fputs($handle, 'RCPT TO: <' . $this->to . '>' . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if ((substr($reply, 0, 3) != 250) && (substr($reply, 0, 3) != 251)) {
                        error_log('Error: RCPT TO not accepted from server!');
                    }
                } else {
                    foreach ($this->to as $recipient) {
                        fputs($handle, 'RCPT TO: <' . $recipient . '>' . $this->crlf);

                        $reply = '';

                        while ($line = fgets($handle, 515)) {
                            $reply .= $line;

                            if (substr($line, 3, 1) == ' ') {
                                break;
                            }
                        }

                        if ((substr($reply, 0, 3) != 250) && (substr($reply, 0, 3) != 251)) {
                            error_log('Error: RCPT TO not accepted from server!');
                        }
                    }
                }

                fputs($handle, 'DATA' . $this->crlf);

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 354) {
                    error_log('Error: DATA not accepted from server!');
                }

                fputs($handle, $header . $message . $this->crlf);
                fputs($handle, '.' . $this->crlf);

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 250) {
                    error_log('Error: DATA not accepted from server!');
                }

                fputs($handle, 'QUIT' . $this->crlf);

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 221) {
                    error_log('Error: QUIT not accepted from server!');
                }

                fclose($handle);
            }
        }
    }
}
?>

 

 

Заменил mail.php на этот и всё работает даже обратная связь на сайте

 

<?php
final class Mail {
    protected $to;
    protected $from;
    protected $sender;
    protected $subject;
    protected $text;
    protected $html;
    protected $attachments = array();
    public $protocol = 'mail';
    public $hostname;
    public $username;
    public $password;
    public $port = 25;
    public $timeout = 5;
    public $newline = "\r\n";
    public $crlf = "\r\n";
    public $verp = FALSE;
    public $parameter = '';

    public function setTo($to) {
        $this->to = $to;
    }

    public function setFrom($from) {
        $this->from = $from;
    }

    public function addheader($header, $value) {
        $this->headers[$header] = $value;
    }

    public function setSender($sender) {
        $this->sender = html_entity_decode($sender);
    }

public function setSubject($subject) {
$this->subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
}

    public function setText($text) {
        $this->text = $text;

    }

    public function setHtml($html) {
        $this->html = $html;
    }

    public function addAttachment($file, $filename = '') {
        if (!$filename) {
            $filename = basename($file);
        }

        $this->attachments[] = array(
            'filename' => $filename,
            'file' => $file
        );
    }

    public function send() {
        if (!$this->to) {
            exit('Error: E-Mail to required!');
        }

        if (!$this->from) {
            exit('Error: E-Mail from required!');
        }

        if (!$this->sender) {
            exit('Error: E-Mail sender required!');
        }

        if (!$this->subject) {
            exit('Error: E-Mail subject required!');
        }

        if ((!$this->text) && (!$this->html)) {
            exit('Error: E-Mail message required!');
        }

        if (is_array($this->to)) {
            $to = implode(',', $this->to);
        } else {
            $to = $this->to;
        }

        $boundary = '----=_NextPart_' . md5(time());

        $header = '';

        if ($this->protocol != 'mail') {
            $header .= 'To: ' . $to . $this->newline;
            $header .= 'Subject: ' . $this->subject . $this->newline;
        }

        $header .= 'Date: ' . date("D, d M Y H:i:s O") . $this->newline;
        //$header .= 'From: "' . $this->sender . '" <' . $this->from . '>' . $this->newline;
        //$header .= 'From: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
        $header .= 'From: ' . '=?UTF-8?B?'.base64_encode($this->sender).'?=' . '<' . $this->from . '>' . $this->newline;
        $header .= 'Reply-To: ' . $this->sender . '<' . $this->from . '>' . $this->newline;
        $header .= 'Return-Path: ' . $this->from . $this->newline;
        $header .= 'X-Mailer: PHP/' . phpversion() . $this->newline;
        $header .= 'MIME-Version: 1.0' . $this->newline;
        $header .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $this->newline;
        $header .= 'Content-Transfer-Encoding: 8bit' . $this->newline;        
        $header .= $this->newline;

        if (!$this->html) {
            $message = '--' . $boundary . $this->newline;
            $message .= 'Content-Type: text/plain; charset="utf-8"' . $this->newline;
            $message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;
            $message .= $this->text . $this->newline;
        } else {
            $message = '--' . $boundary . $this->newline;
            $message .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '_alt"' . $this->newline . $this->newline;
            $message .= '--' . $boundary . '_alt' . $this->newline;
            $message .= '' . $this->newline;
            $message .= '' . $this->newline;

            if ($this->text) {
                $message .= $this->text . $this->newline;
            } else {
                $message .= '' . $this->newline;
            }

            $message .= '--' . $boundary . '_alt' . $this->newline;
            $message .= 'Content-Type: text/html; charset="utf-8"' . $this->newline;
            $message .= 'Content-Transfer-Encoding: 8bit' . $this->newline . $this->newline;
            $message .= $this->html . $this->newline;
            $message .= '--' . $boundary . '_alt--' . $this->newline;
        }

foreach ($this->attachments as $attachment) {
if (file_exists($attachment['file'])) {
$handle = fopen($attachment['file'], 'r');
$content = fread($handle, filesize($attachment['file']));

fclose($handle);

$message .= '--' . $boundary . $this->newline;
$message .= 'Content-Type: application/octetstream' . $this->newline;
$message .= 'Content-Transfer-Encoding: base64' . $this->newline;
$message .= 'Content-Disposition: attachment; filename="' . basename($attachment['filename']) . '"' . $this->newline;
$message .= 'Content-ID: <' . basename($attachment['filename']) . '>' . $this->newline . $this->newline;
$message .= chunk_split(base64_encode($content));
}
}

        $message .= '--' . $boundary . '--' . $this->newline;

        if ($this->protocol == 'mail') {
            ini_set('sendmail_from', $this->from);

            if ($this->parameter) {
                mail($to, '=?UTF-8?B?'.base64_encode($this->subject).'?=', $message, $header, $this->parameter);
            } else {
                mail($to, '=?UTF-8?B?'.base64_encode($this->subject).'?=', $message, $header);
            }

        } elseif ($this->protocol == 'smtp') {
            $handle = fsockopen($this->hostname, $this->port, $errno, $errstr, $this->timeout);

            if (!$handle) {
                error_log('Error: ' . $errstr . ' (' . $errno . ')');
            } else {
                if (substr(PHP_OS, 0, 3) != 'WIN') {
                    socket_set_timeout($handle, $this->timeout, 0);
                }

                while ($line = fgets($handle, 515)) {
                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($this->hostname, 0, 3) == 'tls') {
                    fputs($handle, 'STARTTLS' . $this->crlf);

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 220) {
                        error_log('Error: STARTTLS not accepted from server!');
                    }
                }

                if (!empty($this->username) && !empty($this->password)) {
                    fputs($handle, 'EHLO ' . getenv('SERVER_NAME') . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 250) {
                        error_log('Error: EHLO not accepted from server!');
                    }

                    fputs($handle, 'AUTH LOGIN' . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 334) {
                        error_log('Error: AUTH LOGIN not accepted from server!');
                    }

                    fputs($handle, base64_encode($this->username) . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 334) {
                        error_log('Error: Username not accepted from server!');
                    }

                    fputs($handle, base64_encode($this->password) . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 235) {
                        error_log('Error: Password not accepted from server!');
                    }
                } else {
                    fputs($handle, 'HELO ' . getenv('SERVER_NAME') . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if (substr($reply, 0, 3) != 250) {
                        error_log('Error: HELO not accepted from server!');
                    }
                }

                if ($this->verp) {
                    fputs($handle, 'MAIL FROM: <' . $this->username . '>XVERP' . $this->crlf);
                } else {
                    fputs($handle, 'MAIL FROM: <' . $this->username . '>' . $this->crlf);
                }

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 250) {
                    error_log('Error: MAIL FROM not accepted from server!');
                }

                if (!is_array($this->to)) {
                    fputs($handle, 'RCPT TO: <' . $this->to . '>' . $this->crlf);

                    $reply = '';

                    while ($line = fgets($handle, 515)) {
                        $reply .= $line;

                        if (substr($line, 3, 1) == ' ') {
                            break;
                        }
                    }

                    if ((substr($reply, 0, 3) != 250) && (substr($reply, 0, 3) != 251)) {
                        error_log('Error: RCPT TO not accepted from server!');
                    }
                } else {
                    foreach ($this->to as $recipient) {
                        fputs($handle, 'RCPT TO: <' . $recipient . '>' . $this->crlf);

                        $reply = '';

                        while ($line = fgets($handle, 515)) {
                            $reply .= $line;

                            if (substr($line, 3, 1) == ' ') {
                                break;
                            }
                        }

                        if ((substr($reply, 0, 3) != 250) && (substr($reply, 0, 3) != 251)) {
                            error_log('Error: RCPT TO not accepted from server!');
                        }
                    }
                }

                fputs($handle, 'DATA' . $this->crlf);

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 354) {
                    error_log('Error: DATA not accepted from server!');
                }

                fputs($handle, $header . $message . $this->crlf);
                fputs($handle, '.' . $this->crlf);

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 250) {
                    error_log('Error: DATA not accepted from server!');
                }

                fputs($handle, 'QUIT' . $this->crlf);

                $reply = '';

                while ($line = fgets($handle, 515)) {
                    $reply .= $line;

                    if (substr($line, 3, 1) == ' ') {
                        break;
                    }
                }

                if (substr($reply, 0, 3) != 221) {
                    error_log('Error: QUIT not accepted from server!');
                }

                fclose($handle);
            }
        }
    }
}
?>

Подскажите, пожалуйста, для какой версии?

Надіслати
Поділитися на інших сайтах


  • 4 months later...

Всем здравствуйте! Испытывала аналогичную проблему и пару дней пыталась найти решение на форуме - без успешно((

Проблему решила следующим образом- поделюсь:

Решение относится к "Почте для домена" от yandex'a

Настройки в на вкладке "Почта"

Почтовый протокол: SMTP

SMTP Host: ssl://smtp.yandex.ru (если не указывать ssl, то скорей всего получим ошибку "EHLO not accepted from server!")

SMTP Login: [email protected] (тот который вы привязывали к яндексу. Логин указывается полностью вместе с @)

SMTP пароль: ********* (ваш пароль)

SMTP порт: 465 (согласно правилам указанным на яндексе http://help.yandex.ru/mail/?id=1113199)

SMTP таймаут: 5

А теперь необходимо немного поменять файл mail.php (system/library/mail.php)

Найдите строки:

  if ($this->verp) {
	 fputs($handle, 'MAIL FROM: <' . $this->from . '>XVERP' . $this->crlf);
	} else {
	 fputs($handle, 'MAIL FROM: <' . $this->from . '>' . $this->crlf);
	}
​и замените в них from на username

То есть так:


if ($this->verp) {
	   fputs($handle, 'MAIL FROM: <' . $this->username . '>XVERP' . $this->crlf);
	} else {
	   fputs($handle, 'MAIL FROM: <' . $this->username . '>' . $this->crlf);
	}
тем самым мы обойдём ошибку отказа сервере о том что "е-mail отправителя не принадлежит пользователю, который авторизовался в системе" (https://opencartforum.com/topic/17751-%D0%BF%D0%BE%D1%87%D1%82%D0%B0/page__p__127165#entry127165)

Попробуйте, может у вас тоже всё заработает?!

Версия движка: 1.5.4.1

 

Спасибо! Помогло. Версия 1.5.5.1.2

Змінено користувачем baybak
Надіслати
Поділитися на інших сайтах


  • 3 weeks later...
  • 1 month later...

Notice: Error: EHLO not accepted from server! in /home/a/a96509n6/a96509n6.bget.ru/public_html/system/library/mail.php on line 199

нашел решение https://opencartforum.com/topic/59042-%D0%BD%D0%B0%D1%81%D1%82%D1%80%D0%BE%D0%B9%D0%BA%D0%B0-smpt-%D0%BF%D1%80%D0%BE%D1%82%D0%BE%D0%BA%D0%BE%D0%BB%D0%B0/

Надіслати
Поділитися на інших сайтах


  • 2 months later...

У меня так же всё заработало

OcStore 2.1.0.2.

Что бы резюмировать:

для настройки под yandex в рамках именно в этой ветки для ocstore 2.x - не ковыряйте файл mail.php - его нужно оставить с дефолтными значениями везде. Менять нужно именно contact.php

все заработало со след настройками в админке

smtp host: ssl://smtp.yandex.ru,

smtp логин: [email protected]

smtp порт: 465

smtp таймаут: 5

Надіслати
Поділитися на інших сайтах


  • 3 weeks later...

Настраивал почтовую рассылку от родного почтового сервера для Opencart 2. В принципе автора можно понять - он выставил в поля "from" и "reply to" email залогиненного администратора, который не обязательно совпадает smtp логином. Однако это неверно с точки зрения DMARC policy. From должен быть с того же домена, что и почтовый сервер. Грубо говоря, если рассылка идет через yandex, то и from должен быть [email protected], а не [email protected]. Фиксается заменой в mail.php всех $this->from на $this->smtp_username (или на $this->username для Opencart 1.5+).

  • +1 1
Надіслати
Поділитися на інших сайтах


  • 6 months later...
В 20.03.2013 в 08:38, finikys сказал:

Всем здравствуйте! Испытывала аналогичную проблему и пару дней пыталась найти решение на форуме - без успешно((

Проблему решила следующим образом- поделюсь:

Решение относится к "Почте для домена" от yandex'a

Настройки в на вкладке "Почта"

Почтовый протокол: SMTP

SMTP Host: ssl://smtp.yandex.ru (если не указывать ssl, то скорей всего получим ошибку "EHLO not accepted from server!")

SMTP Login: [email protected] (тот который вы привязывали к яндексу. Логин указывается полностью вместе с @)

SMTP пароль: ********* (ваш пароль)

SMTP порт: 465 (согласно правилам указанным на яндексе http://help.yandex.ru/mail/?id=1113199)

SMTP таймаут: 5

А теперь необходимо немного поменять файл mail.php (system/library/mail.php)

Найдите строки:


 if ($this->verp) {
 fputs($handle, 'MAIL FROM: <' . $this->from . '>XVERP' . $this->crlf);
} else {
 fputs($handle, 'MAIL FROM: <' . $this->from . '>' . $this->crlf);
}
 

и замените в них from на username

То есть так:


if ($this->verp) {
   fputs($handle, 'MAIL FROM: <' . $this->username . '>XVERP' . $this->crlf);
} else {
   fputs($handle, 'MAIL FROM: <' . $this->username . '>' . $this->crlf);
}
 

тем самым мы обойдём ошибку отказа сервере о том что "е-mail отправителя не принадлежит пользователю, который авторизовался в системе" (https://opencartforum.com/topic/17751-%D0%BF%D0%BE%D1%87%D1%82%D0%B0/page__p__127165#entry127165)

Попробуйте, может у вас тоже всё заработает?!

Версия движка: 1.5.4.1

Подтверждаю - работает. Теперь письма приходят мгновенно!!!

Надіслати
Поділитися на інших сайтах


  • 4 months later...

У меня домен делегирован на dns Яндекса, создана почта для домена, получилось рассылать почту через smtp только сгенерировав пароль для приложения в настройках почты. Инструкция от Яндекса: https://yandex.ru/support/passport/authorization/app-passwords.html

Настройки на вкладке "Почта"

Почтовый протокол: SMTP

SMTP Host: ssl://smtp.yandex.ru (если не указывать ssl, то скорей всего получим ошибку "EHLO not accepted from server!")

SMTP Login: [email protected] (тот который вы привязывали к яндексу. Логин указывается полностью вместе с @)

SMTP пароль: ********* (пароль для приложения, сгенерированный в настройках аккаунта Яндекса )

SMTP порт: 465

SMTP таймаут: 5

Надіслати
Поділитися на інших сайтах


  • 3 months later...
On 20.03.2013 at 8:38 AM, finikys said:

Всем здравствуйте! Испытывала аналогичную проблему и пару дней пыталась найти решение на форуме - без успешно((

Проблему решила следующим образом- поделюсь:

Решение относится к "Почте для домена" от yandex'a

Настройки в на вкладке "Почта"

Почтовый протокол: SMTP

SMTP Host: ssl://smtp.yandex.ru (если не указывать ssl, то скорей всего получим ошибку "EHLO not accepted from server!")

SMTP Login: [email protected] (тот который вы привязывали к яндексу. Логин указывается полностью вместе с @)

SMTP пароль: ********* (ваш пароль)

SMTP порт: 465 (согласно правилам указанным на яндексе http://help.yandex.ru/mail/?id=1113199)

SMTP таймаут: 5

А теперь необходимо немного поменять файл mail.php (system/library/mail.php)

Найдите строки:


 if ($this->verp) {
 fputs($handle, 'MAIL FROM: <' . $this->from . '>XVERP' . $this->crlf);
} else {
 fputs($handle, 'MAIL FROM: <' . $this->from . '>' . $this->crlf);
}
 

и замените в них from на username

То есть так:


if ($this->verp) {
   fputs($handle, 'MAIL FROM: <' . $this->username . '>XVERP' . $this->crlf);
} else {
   fputs($handle, 'MAIL FROM: <' . $this->username . '>' . $this->crlf);
}
 

тем самым мы обойдём ошибку отказа сервере о том что "е-mail отправителя не принадлежит пользователю, который авторизовался в системе" (https://opencartforum.com/topic/17751-%D0%BF%D0%BE%D1%87%D1%82%D0%B0/page__p__127165#entry127165)

Попробуйте, может у вас тоже всё заработает?!

Версия движка: 1.5.4.1

Всё верно, у меня всё заработало без проблем, но есть одно но - Вы пробывали через форму обратной связи отправить любое сообщение но вставить именно @mail.ru в поле почта и отправить, мне лично уведомления не приходят((( А вот любую другую почту укажу в форме и отправлю, всё чётко, уведомления приходят. В чём может быть причина?

Надіслати
Поділитися на інших сайтах


  • 3 months later...
В 21.02.2016 в 13:50, anechkin сказал:

Кому может пригодится. Настройка для mail.ru

 

WXtAOn7.png

У меня тоже при переезде перестало работать уведомление о заказе, также на mail.ru была почта для заказов (нравится mail.ru Агент). Да, почта домена обрабатывалась тоже яндексом, и меня начал лечить хостер, что надо указывать из-за этого smtp яндекса, раз сделана mx-запись об этоб. Хрен, решение просто открыть 465 порт. И люди здесь не зря пишут о том, что почта в Общих настройках и Почте должна быть одинакова, она для заказов. Не надо пихать туда почту для домена от яндекса, куча проблем, почта от яндекса для домена может работать  отдельно, например для спама и коммерческих предложений и других целей.. Не надо ее указывать в настройках!!!

И кстати, в параметрах функции mail при использовании протокола mail можно указать -f{пробел}{любая ваша другая почта}, что значит: -f=from отправитель письма, и  не надо править mail.php .  На некоторых хостингах работает. 

Как правило, основная проблема - это закрытые порты!

Змінено користувачем pahanmcs
Надіслати
Поділитися на інших сайтах


  • 1 year later...

У меня стоит форма обратной связи с отправкой письма не только на мой email но и на email отправителю. При отправке сообщения отправителю получается что как будто письмо отправлено не от меня а от моего хостера. Адрес электронной почты хостера  прописывается , А хотелось бы чтобы прописывался мой. Общение с хостером результатов не принесло. Может кто-то сталкивался с подобным... 

Надіслати
Поділитися на інших сайтах


  • 1 month later...

Добрый день знатоки, подскажите opencard 3.0.2 как решить проблему отправка по smtp yandex

все работает все хорошо

но вот если пользователь отправляет с формы обратной связи то мне приходит письмо от меня же и ответить не представляется возможным так как не известно мыло отправителя.

Как решить данную беду?

Надіслати
Поділитися на інших сайтах


  • 1 year later...
  • 11 months later...

Створіть аккаунт або увійдіть для коментування

Ви повинні бути користувачем, щоб залишити коментар

Створити обліковий запис

Зареєструйтеся для отримання облікового запису. Це просто!

Зареєструвати аккаунт

Вхід

Уже зареєстровані? Увійдіть тут.

Вхід зараз
  • Зараз на сторінці   0 користувачів

    • Ні користувачів, які переглядиють цю сторінку

×
×
  • Створити...

Important Information

На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність.