Answer the question
In order to leave comments, you need to log in
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>
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>
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>
$ app/console mail:send --to="[email protected]" --body="Тест:)" --subject="тест"<br>
To: [email protected]<br>
Subject: тест<br>
Body: Тест:)<br>
Result: 1<br>
Answer the question
In order to leave comments, you need to log in
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();
}
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:
mailer_transport: smtp
mailer_host: smtp.yandex.ru
mailer_user: *****@********
mailer_password: *********
mailer_encryption: ssl
mailer_auth_mode: login
mailer_port: 465
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
MAILER_DSN=smtp://login:[email protected]:465
smtp yandex Error: authentication failed: This user does not have access rights to this service
Mail -> All settings -> Mail programs
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question