Paul Czerner
0
Q:

Expected response code 250 but got code "501", with message "501 5.5.4 Invalid domain name

public function sendMessage()
    {

        $transport = (new \Swift_SmtpTransport('smtp.office365.com', 25, 'tls'))
            ->setUsername('[email protected]')
            ->setPassword('YourPassword');
        $transport->setLocalDomain('[127.0.0.1]');  //<= add this to your code
        $mailer = new \Swift_Mailer($transport);

        try {
            $message = (new \Swift_Message($this->Subject))
                ->setFrom(array('[email protected]' => "Subject"))
                ->setTo( $this->Email)
                //->setBcc($client)
                ->setBody($this->text, 'text/html');
            $mailer->send($message);

        } catch (\Exception $e) {
            return $e->getMessage();
        }

        return 1;

    }
0

New to Communities?

Join the community