Fatal error: Uncaught exception 'Swift_TransportException' with message 'Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. fb9sm57232081wid.2 - gsmtp "' in C:\xampp\htdocs\lib\classes\Swift\Transport\AbstractSmtpTransport.php:386 Stack trace: #0 C:\xampp\htdocs\lib\classes\Swift\Transport\AbstractSmtpTransport.php(281): Swift_Transport_AbstractSmtpTransport->_assertResponseCode('530 5.7.0 Must ...', Array) #1 C:\xampp\htdocs\lib\classes\Swift\Transport\EsmtpTransport.php(245): Swift_Transport_AbstractSmtpTransport->executeCommand('MAIL FROM: executeCommand('MAIL FROM: _doMailFromCommand('sophie3394@gm...')
4 C:\xampp\htdocs\lib\classes\Swift\Transport\AbstractSmtpTransport.php(444):
Swift_Transport_AbstractSmt in C:\xampp\htdocs\lib\classes\Swift\Transport\AbstractSmtpTransport.php on line 386
This is the error caused by the following code:
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");
require_once 'lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 25)
->setUsername('[email protected]')
->setPassword('xxxx');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Test Subject')
->setFrom(array('[email protected]' => 'ABC'))
->setTo(array('[email protected]'))
->setBody('This is a test mail.');
$result = $mailer->send($message);
What are the steps to resolve this error?
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? #1899472503]' in C:\xampp\htdocs\lib\classes\Swift\Transport\StreamBuffer.php:259 Stack trace: #0 C:\xampp\htdocs\lib\classes\Swift\Transport\StreamBuffer.php(64): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 C:\xampp\htdocs\lib\classes\Swift\Transport\AbstractSmtpTransport.php(115): Swift_Transport_StreamBuffer->initialize(Array) #2 C:\xampp\htdocs\lib\classes\Swift\Mailer.php(80): Swift_Transport_AbstractSmtpTransport->start() #3 C:\xampp\htdocs\Mail.php(26): Swift_Mailer->send(Object(Swift_Message)) #4 {main} thrown in C:\xampp\htdocs\lib\classes\Swift\Transport\StreamBuffer.php on line 259