N
N
Nikita Gusakov2013-10-18 17:53:21
symfony
Nikita Gusakov, 2013-10-18 17:53:21

How to make swiftmailer friends with Yandex.pdd?

Tried to send via telnet:

$ telnet smtp.yandex.ru 25<br>
Trying 77.88.21.38...<br>
Connected to smtp.yandex.ru.<br>
Escape character is '^]'.<br>
220 smtp12.mail.yandex.net ESMTP (Want to use Yandex.Mail for your domain? Visit http://pdd.yandex.ru)<br>
EHLO yandex.ru<br>
250-smtp12.mail.yandex.net<br>
250-8BITMIME<br>
250-PIPELINING<br>
250-SIZE 42991616<br>
250-STARTTLS<br>
250-AUTH LOGIN PLAIN<br>
250-DSN<br>
250 ENHANCEDSTATUSCODES<br>
AUTH LOGIN<br>
334 VXNlcm5hbWU6<br>
bWFpbEBua3QubWU=<br>
334 UGFzc3dvcmQ6<br>
*******<br>
235 2.7.0 Authentication successful.<br>
MAIL FROM:[email protected]  <br>
250 2.1.0 <[email protected]> ok<br>
RCPT TO:[email protected]<br>
250 2.1.5 <[email protected]> recipient ok<br>
DATA<br>
354 Enter mail, end with "." on a line by itself<br>
Subject: Q^BP5Q^AQ^B<br>
To: [email protected]<br>
.<br>
250 2.0.0 Ok: queued on smtp12.mail.yandex.net as 6VPPHaRoyW-LYnSwHm7<br>
QUIT<br>
221 2.0.0 Closing connection.<br>
Connection closed by foreign host.<br>

Everything is ok, everything went.
Added to app/config/parameters.yml:
mailer_transport: smtp<br>
mailer_host:      smtp.yandex.ru<br>
mailer_user:      [email protected]<br>
mailer_password:  *****<br>
mailer_auth_mode:  login<br>
mailer_encryption: ~<br>
mailer_port:       25<br>

I'm trying to send an email:
protected function execute(InputInterface $input, OutputInterface $output)<br>
{<br>
    $mailer = $this->getContainer()->get('mailer');<br>
    $to = $input->getOption('to');<br>
    $subject = $input->getOption('subject');<br>
    $body = $input->getOption('body');<br>
    $message = \Swift_Message::newInstance()<br>
        ->setTo($to)<br>
        ->setSubject($subject)<br>
        ->setBody($body);<br>
    $output->writeln('To: ' . $to);<br>
    $output->writeln('Subject: ' . $subject);<br>
    $output->writeln('Body: ' . $body);<br>
    $output->writeln('Result: ' . $mailer->send($message));<br>
}<br>

I run and the result is:
$ app/console mail:send --to="[email protected]" --body="Тест:)" --subject="тест"<br>
To: [email protected]<br>
Subject: тест<br>
Body: Тест:)<br>
Result: 1<br>

Well, actually there is no letter, otherwise I would not have written a question.
I played with ssl and ports, how to understand what the plug is?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
N
Nikita Gusakov, 2013-10-18
@hell0w0rd

It turns out this is how it should be:

protected function execute(InputInterface $input, OutputInterface $output)
{
    $mailer = $this->getContainer()->get('mailer');
    $transport = $mailer->getTransport();
    $transport->start();
    $message = \Swift_Message::newInstance(
        $input->getOption('subject'),
        $input->getOption('body'),
        $input->getOption('content-type'),
        $input->getOption('charset')
    )
        ->setFrom(['[email protected]' => 'Admin'])
        ->setTo($input->getOption('to'));
    $output->writeln(sprintf('Sent %s emails', $transport->send($message)));
    $transport->stop();
}

Meaning in start-stop

K
keltanas, 2013-12-05
@keltanas

In general, I did not quite understand what you want to do and what you achieved by this. But I act like this:
config.yml

swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    port:      %mailer_port%
    username:  %mailer_user%
    encryption: %mailer_encryption%
    auth_mode:  %mailer_auth_mode%
    password:  %mailer_password%
    spool: 
        type: file
        path: "%kernel.root_dir%/../spool"

parameters.yml
parameters:
    mailer_transport: smtp
    mailer_host: smtp.yandex.ru
    mailer_user: *****@********
    mailer_password: *********
    mailer_encryption: ssl
    mailer_auth_mode: login
    mailer_port: 465

Further in the code, you simply send:
And you screw it into the crowns with absolute paths:
Everything, Profit.

V
Vyacheslav Slinko, 2013-10-18
@KeepYourMind

Try setting From equal to login.

T
tyomo4ka, 2013-10-18
@tyomo4ka

Try running the command in prod mode instead of dev ;)

J
jetfx, 2021-03-10
@jetfx

If you try to make Symfony 5.2 Mailer friends with Yandex Mail:
1. Install the bundle according to the instructions: https://symfony.com/doc/current/mailer.html
2. Create an account in Yandex Mail.
3. Set up Yandex Mail. With a password from your mail, Yandex will not let you in for security reasons. Therefore, in order to connect to SMTP from the outside, you need an application password. You can create it in the settings:

Mail -> All Settings -> Security -> App Passwords

60485519db506674760280.png
4. In the project itself, add the following line to the .env configuration file:
MAILER_DSN=smtp://login:[email protected]:465

where login is the part of your mail before the dog (i.e. [email protected]), password is the application password created in step 3.
5. If after all the settings in Symfony an error occurs:
smtp yandex Error: authentication failed: This user does not have access rights to this service

Come in
Mail -> All settings -> Mail programs

and check the box next to IMAP, as in the picture:
60485380c0fcd631711369.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question