Witam,
Mam prosty formularz po wypełnieniu którego wysyła się mail. Cały czas wywala mi błąd:
Expected response code "250" but got code "550", with message "550 5.1.8 Sender address rejected".
Używam w Symfony paczki symfony/mailer
Moje ustawienia połącznia w pliku .env.local.php:
'MAILER_DSN' => 'smtp://admin@mojadomena.pl:mojehaslo@mojhost:465',
MailerController:
<?php
namespace App\Controller;
use App\Form\MailerType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Mime\Email;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\HttpFoundation\Response;
class MailerController extends AbstractController
{
/**
* @Route("/email", name="mailer")
* @param MailerInterface $mailer
* @return Response
*/
public function sendEmail(Request $request, MailerInterface $mailer)
{
$form = $this->createForm(MailerType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$contactFormData = $form->getData();
$email = (new Email())
->from('test@o2.pl')
->to('admin@mojadomena.pl')
->subject('Time for Symfony Mailer!')
->text('Sending emails is fun again!');
$mailer->send($email);
return $this->redirectToRoute('mailer');
}
return $this->render('mailer/index.html.twig', [
'our_form' => $form->createView()
]);
}
}
Swoją drogą wcześniej miałem błąd że wysyłam spam i moja wiadomość jest blokowana :O
Edit: Skonfigurowałem w ramach testu poczte w thunderbird i bez problemu odbieram wysyłam maile korzystajac z tego serwera pocztowego
Edit2:
Stworzylem mała aplikacje poza symfony i tak wyglada log :
test poczty
2020-11-23 11:04:38 CLIENT -> SERVER: MAIL FROM:<piotrzakrzewski89@gmail.com>
2020-11-23 11:04:38 SERVER -> CLIENT: 550 5.1.8 Sender address rejected
2020-11-23 11:04:38 SMTP ERROR: MAIL FROM command failed: 550 5.1.8 Sender address rejected
The following From address failed: piotrzakrzewski89@gmail.com : MAIL FROM command failed,Sender address rejected,550,5.1.8SMTP server error: MAIL FROM command failed Detail: Sender address rejected SMTP code: 550 Additional SMTP info: 5.1.8
Problem in Sending Mail.
index.php:
<?php
echo "test poczty<br><br>";
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require('src/Exception.php');
require('src/PHPMailer.php');
require('src/SMTP.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 3;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->Username = "uzytkownik@mojadomena.pl";
$mail->Password = "haslo";
$mail->Host = "serwer00000.home.pl";
$mail->Mailer = "smtp";
$mail->SetFrom('piotrzakrzewski89@gmail.com');
$mail->AddAddress("uzytkownik@mojadomena.pl");
$mail->Subject = "KONTAKT";
$mail->WordWrap = 80;
$mail->Subject = "Testowa wiadomość SMTP"; /* Tytuł wiadomości */
$mail->Body = "Witaj, Jeżeli to czytasz, to znaczy, że udało się poprawnie wysłać e-maila za pomocą SMTP!";
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "<p class='error'>Problem in Sending Mail.</p>";
} else {
echo "<p class='success'>Contact Mail Sent.</p>";
}