B
B
byms2015-05-21 16:52:44
linux
byms, 2015-05-21 16:52:44

Yii stmp Connect() failed, how to solve?

www.yiiframework.com/extension/yiimailer I use this lib, smtp.yandex.ru, everything works on one server, transferred to another server, sending letters does not work, writes SMTP Connect () failed, what could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Grechushnikov, 2015-05-21
@maxyc_webber

show smtp settings and how you send email

B
byms, 2015-05-21
@byms

<?php
return array(
    'viewPath' => 'application.views.mail',
    'layoutPath' => 'application.views.layouts',
    'baseDirPath' => 'webroot.images.mail',
    'layout' => 'mail',
    'CharSet' => 'UTF-8',
    'AltBody' => Yii::t('YiiMailer','Новое сообщение с сайта'),
    'Mailer' => 'smtp',
    'Host' => 'smtp.yandex.ru',
    'Port' => 465,
    'SMTPSecure' => 'ssl',
    'SMTPAuth' => true,
    'Username' => '[email protected]',
    'Password' => '123',
    'language' => array(
    'authenticate'         => Yii::t('YiiMailer','SMTP Error: Could not authenticate.'),
    'connect_host'         => Yii::t('YiiMailer','SMTP Error: Could not connect to SMTP host.'),
    'data_not_accepted'    => Yii::t('YiiMailer','SMTP Error: Data not accepted.'),
    'empty_message'        => Yii::t('YiiMailer','Message body empty'),
    'encoding'             => Yii::t('YiiMailer','Unknown encoding: '),
    'execute'              => Yii::t('YiiMailer','Could not execute: '),
    'file_access'          => Yii::t('YiiMailer','Could not access file: '),
    'file_open'            => Yii::t('YiiMailer','File Error: Could not open file: '),
    'from_failed'          => Yii::t('YiiMailer','The following From address failed: '),
    'instantiate'          => Yii::t('YiiMailer','Could not instantiate mail function.'),
    'invalid_address'      => Yii::t('YiiMailer','Invalid address'),
    'mailer_not_supported' => Yii::t('YiiMailer',' mailer is not supported.'),
    'provide_address'      => Yii::t('YiiMailer','You must provide at least one recipient email address.'),
    'recipients_failed'    => Yii::t('YiiMailer','SMTP Error: The following recipients failed: '),
    'signing'              => Yii::t('YiiMailer','Signing Error: '),
    'smtp_connect_failed'  => Yii::t('YiiMailer','SMTP Connect() failed.'),
    'smtp_error'           => Yii::t('YiiMailer','SMTP server error: '),
    'variable_set'         => Yii::t('YiiMailer','Cannot set or reset variable: ')
    ),
);

public function renderForm1()
    {
        $model = new Form;

        // uncomment the following code to enable ajax-based validation

        if(isset($_POST['ajax']) && $_POST['ajax']==='form1')
        {
            echo CActiveForm::validate($model);
            Yii::app()->end();
        }

        if(isset($_POST['Form']))
        {
            $model->attributes=$_POST['Form'];
            if($model->save())
            {
                $msg = new YiiMailer('form1', array('model' => $model));
                $msg->render();
                $msg->Subject = 'Новое сообщение через форму (Заказать звонок)';
                $msg->AddAddress(Yii::app()->params['adminEmail']);
        $msg->setFrom('[email protected]', Yii::app()->params['title']);


                if ($msg->Send()) {
                    $msg->ClearAddresses();
          Yii::app()->user->setFlash('success','Ваше сообщение отправлено.');
                    Yii::app()->controller->redirect(CHtml::normalizeUrl(array('')+$_GET));
                } else {
                    Yii::app()->user->setFlash('error','Проблема: '.$msg->ErrorInfo);
                    Yii::app()->controller->redirect(CHtml::normalizeUrl(array('')+$_GET));
                }
            }
        }
        $this->render('/form/form1',array('model'=>$model));
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question