1

I am working on swiftmailer php library. Actually I am facing an error like this: Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. k127sm385513pgk.10 - gsmtp".

I am not getting what is the reason behind that. Can i get any guidance related to this issue? You can see my code below.

try
{
    $transport = (new Swift_SmtpTransport('smtp.gmail.com', 587))

        ->setUsername('my@gmail.com')

        ->setPassword('*****');

        $transport->setStreamOptions([
            'ssl' => ['allow_self_signed' => true, 'verify_peer' => false, 'verify_peer_name' => false]
        ]);

    $mailer = new Swift_Mailer($transport);

    $message = new Swift_Message();

    $message->setSubject("Notification");

    $message->setFrom(['my@gmail.com' => "known"]);

    $message->setTo(['reciepent@gmail.com' => "known"]);

    $content = "hi";
    $message->setBody($content);

    $result = $mailer->send($message);
}
catch (Exception $e) 
{     
    echo $e->getMessage();  
}
miile7
  • 2,547
  • 3
  • 23
  • 38
GIRISH R
  • 11
  • 3
  • Does this answer your question? [PHP - Swiftmailer using STARTTLS and self signed certificates](https://stackoverflow.com/questions/26896265/php-swiftmailer-using-starttls-and-self-signed-certificates) – Vlam Oct 20 '20 at 05:58
  • thank you for the quick response. but the link what you have provided is not relating to my issue..is there any other solution to resolve that. – GIRISH R Oct 20 '20 at 06:12

1 Answers1

1

Can you specify the tls like the below?

new Swift_SmtpTransport('smtp.gmail.com', 587, 'tls')
Vlam
  • 1,622
  • 1
  • 8
  • 17
  • i tried the above code.but still am facing the same issue. with having error message like this-> "Failed to authenticate on SMTP server with username "my@gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. . thank you – GIRISH R Oct 20 '20 at 06:31
  • Please see https://support.google.com/mail/thread/5621336?hl=en – Vlam Oct 20 '20 at 08:07