H
H
HeBonpoc2014-11-14 23:18:56
Yii
HeBonpoc, 2014-11-14 23:18:56

How to set up sending mail from hosting?

I just tried digitalocean.com to set up sending mail from PHP, and, of course, I ran into the fact that earlier on hostings for mere mortals it was enough to call mail (), and in extreme cases, press a couple of buttons in the ISP panel, and now I have to tinker myself .

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' => false,
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.yandex.ru',
                'username' => '[email protected]',
                'password' => 'pass',
                'port' => '25',
                'encryption' => 'tls',
            ],
        ],

And I tried port 465, and removed encryption, and put it on ssl and tried Google, but all to no avail. It gave
SWIFT MAILER ERROR : Expected response code 250 but got code " "
and the fact that the script ended because the default 30 seconds are over, and that can't establish a connection with smtp.yandex.ru and just empty content, although there are a lot of things right after sending var_dump. Then
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

I made a self-made certificate, which, of course, did not help to remove this error.
Please send.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
HeBonpoc, 2014-11-15
@HeBonpoc

If you have the same problem, then try:
1. Install sendmail. For me it was apt-get install sendemail
2. Set the path to sendemail in php.ini. I have this line sendmail_path = /usr/sbin/sendmail -t -i
3. I managed to connect to Yandex with encryption tls and port 25
4. The openssl extension should be installed. If phpinfo() shows that openssl is enabled and you have rebooted the server, this does not mean that the extension is enabled and working. It was a discovery for me :( You also need to add extension=openssl.so to php.ini

B
Boris Benkovsky, 2014-11-14
@benbor

The answer is off topic. But to control and maintain your mail server, without the need for extra work. Yes, and your letters will be in spam, without certificates. There are a lot of mail delivery services that free us (developers) from unnecessary work. Personally, I use sendgrid.net for free 200 emails per day, there is a rest api and smtp

G
glsv, 2019-12-04
@glsv

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.yandex.ru',
                'username' => '***',
                'password' => '***',
                'port' => '587',
                'encryption' => 'tls',
                'streamOptions' => [
                    'ssl' => [
                        'verify_peer' => false,
                        'verify_peer_name' => false,
                    ]
                ]
            ],
        ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question