Note that there are some explanatory texts on larger screens.

plurals
  1. POSwiftmailer not send mail by smtp
    primarykey
    data
    text
    <p>First I tried send it using <code>telnet</code>:</p> <pre><code>$ telnet smtp.yandex.ru 25 Trying 77.88.21.38... Connected to smtp.yandex.ru. Escape character is '^]'. 220 smtp12.mail.yandex.net ESMTP (Want to use Yandex.Mail for your domain? Visit http://pdd.yandex.ru) EHLO yandex.ru 250-smtp12.mail.yandex.net 250-8BITMIME 250-PIPELINING 250-SIZE 42991616 250-STARTTLS 250-AUTH LOGIN PLAIN 250-DSN 250 ENHANCEDSTATUSCODES AUTH LOGIN 334 VXNlcm5hbWU6 bWFpbEBua3QubWU= 334 UGFzc3dvcmQ6 ******* 235 2.7.0 Authentication successful. MAIL FROM:mail@nkt.me 250 2.1.0 &lt;mail@nkt.me&gt; ok RCPT TO:dev@nkt.me 250 2.1.5 &lt;dev@nkt.me&gt; recipient ok DATA 354 Enter mail, end with "." on a line by itself Subject: Q^BP5Q^AQ^B To: dev@nkt.me . 250 2.0.0 Ok: queued on smtp12.mail.yandex.net as 6VPPHaRoyW-LYnSwHm7 QUIT 221 2.0.0 Closing connection. Connection closed by foreign host. </code></pre> <p>All is ok, I got the mail Then I setup swiftmailer params:</p> <pre><code>mailer_transport: smtp mailer_host: smtp.yandex.ru mailer_user: mail@nkt.me mailer_password: ***** mailer_auth_mode: login mailer_encryption: ~ mailer_port: 25 </code></pre> <p>And create command for send emails:</p> <pre><code>class SendMailCommand extends ContainerAwareCommand { protected function configure() { $this -&gt;setName('mail:send') -&gt;setDescription('Send email') -&gt;addOption('to', null, InputOption::VALUE_REQUIRED, 'Destination email address') -&gt;addOption('body', 'b', InputOption::VALUE_REQUIRED, 'Mail body') -&gt;addOption('subject', 'sub', InputOption::VALUE_OPTIONAL, 'Mail title'); } protected function execute(InputInterface $input, OutputInterface $output) { $mailer = $this-&gt;getContainer()-&gt;get('mailer'); $to = $input-&gt;getOption('to'); $subject = $input-&gt;getOption('subject'); $body = $input-&gt;getOption('body'); $message = \Swift_Message::newInstance() -&gt;setTo($to) -&gt;setSubject($subject) -&gt;setBody($body); $output-&gt;writeln('To: ' . $to); $output-&gt;writeln('Subject: ' . $subject); $output-&gt;writeln('Body: ' . $body); $output-&gt;writeln('Result: ' . $mailer-&gt;send($message)); } } </code></pre> <p>And run it:</p> <pre><code>$ app/console mail:send --to="dev@nkt.me" --body="Test body" --subject="Test" To: dev@nkt.me Subject: Test Body: Test body Result: 1 </code></pre> <p>Well, actually not, otherwise I wouldn't have posted the question. I tried to use ssl, but still not working, what could be the problem?</p> <p>PS Now i get smtp instead of spool:</p> <pre><code>protected function execute(InputInterface $input, OutputInterface $output) { $mailer = $this-&gt;getContainer()-&gt;get('swiftmailer.transport.real'); $message = \Swift_Message::newInstance() -&gt;setFrom(['mail@nkt.me' =&gt; 'Admin']) -&gt;setTo($input-&gt;getOption('to')) -&gt;setSubject($input-&gt;getOption('subject')) -&gt;setBody($input-&gt;getOption('body')); $output-&gt;writeln(sprintf('Sent %s emails', $mailer-&gt;send($message))); } </code></pre> <p>But also get error:</p> <pre><code>[Swift_TransportException] Expected response code 250 but got code "", with message "" </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload