Hi, I have problems with send email with SMTP, I have to use SMTP because proc_open is disable in my shared hosting. At first I configured the SMTP to send emails through yandex and it worked perfect but the days passed and some emails did not arrive, I saw the log file and found this error:
flarum.ERROR: Swift_TransportException: Expected response code 250 but got code "554", with message "554 5.7.1 [2] Message rejected under suspicion of SPAM; https://ya.cc/1IrBc 1606282776-3gmjw6ifHe-dZIOvhgd
I would have to discard yandex, so I tried it with the SMTP of my shared hosting, it never passed the sending test, I looked at the log file and found a new error:
POST https://myserver/api/mail/test
Swift_TransportException: Expected response code 354 but got code "503", with message "503-All RCPT commands were rejected with this error:
503-No such recipient here
503 Valid RCPT command must precede DATA
" in /vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457
I decided to test on my local server, which I have installed on my pc, and the same error happened, I disabled all third-party extensions and nothing changed, the error continued.
Before contacting the technical support of my hosting provider to find out if it was a problem that existed on the server, I decided to download the swiftmailer on my local server to test if my shared hosting service had problems with SMTP, for testing use the following script:
<?php
// load composer packages
require __DIR__ . '/vendor/autoload.php';
// SMTP server configuration
$smtp_server = 'mail.myserver.com';
$username = 'comunidad@myserver.com';
$password = 'pass';
$port = '587';
$encryption = 'tls';
// create message
$message = (new Swift_Message('Test Message Using SMTP Protocol!'))
->setFrom(['comunidad@myserver.com' => 'Admin'])
->setTo(['myemail@gmail.com' => 'Normal User'])
->setBody('This is Message body from Swift mailer SMTP test script!');
// create transport
$transport = (new Swift_SmtpTransport($smtp_server, $port, $encryption))
->setUsername($username)
->setPassword($password);
// pass transport to the swift mailer
$mailer = new Swift_Mailer($transport);
// send email
$result = $mailer->send($message);
if ($result) {
echo "Message has been successfully sent!";
}
It worked perfectly, there was no problem with the SMTP service of my shared hosting, to verify this, I uploaded the script to the server, where the flarum is installed, and it also worked correctly.
I got to a point where I don't know what to do to solve the problem, if someone with more experience could help me, I would really appreciate it. Thanks