Frage

Hier ist mein PHP-Code:

function SendCookieToTheMail()
{
    require_once 'swift-mailer/lib/swift_required.php';
    //Create the Transport
    $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com')
      ->setPort(465)
      ->setEncryption('ssl')
      ->setUsername('007@gmail.com')
      ->setPassword('123')
      ;

    //Create the Mailer using your created Transport
    $mailer = Swift_Mailer::newInstance($transport);

    //Create a message
    $message = Swift_Message::newInstance('Test')
      ->setFrom(array('007@gmail.com' => 'From mr. 007'))
      ->setTo(array('007@gmail.com', '007@gmail.com' => 'To mr. 007'))
      ->setBody('Body')
      ;

    //Send the message
    $result = $mailer->send($message);

    /*
    You can alternatively use batchSend() to send the message

    $result = $mailer->batchSend($message);
    */ 
}

Hier ist der Fehler:

( ! ) Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\Program Files\wamp\www\swift-mailer\lib\classes\Swift\Transport\StreamBuffer.php on line 233

( ! ) 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? #44551400]' in C:\Program Files\wamp\www\swift-mailer\lib\classes\Swift\Transport\StreamBuffer.php on line 235

( ! ) Swift_TransportException: 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? #44551400] in C:\Program Files\wamp\www\swift-mailer\lib\classes\Swift\Transport\StreamBuffer.php on line 235

Wo liegt das Problem?

Update:

Ich habe den phpinfo() überprüft und es heißt:

OpenSSL support     disabled (install ext/openssl) 

Ich habe auf die folgenden Links verwiesen, konnte aber ssl nicht installieren ...

War es hilfreich?

Lösung

Hat Ihr PHP SSL unterstützt? http://php.net/manual/en/function.fsockopen.php und überprüfen Sie http://www.php.net/manual/en/openssl.installation.php als Referenz.

Erstellen Sie eine Seite mit

phpinfo();

Ist SSL aktiviert?

Andere Tipps

Ich habe nach einer ähnlichen Frage gesucht und festgestellt, dass Sie die Datei php.ini bearbeiten müssen Bearbeiten Sie die folgende Zeile

;extension=php_openssl.dll

Entfernen Sie das Semikolon und es wird gut funktionieren

Hoffe, dass jemand anderem hilft :)

Google Mail benötigt dies in Ihrer config.yml

Swiftmailer: Verschlüsselung: tls

oder ersetzen Sie Ihre: -> setEncryption ('ssl') durch -> setEncryption ('tls')

und nicht ssl

Sie sollten das Modul php_openssl über PHP-Erweiterungen aktivieren.Bearbeiten Sie einfach Ihre php.ini -Datei

extension=php_openssl.dll

Tatsächlich rate ich, tls auf Port 25 zu verwenden Testen Sie mit der folgenden Syntax:

$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 25, 'tls')
    ->setUsername('007@gmail.com')
    ->setPassword('123');

Sie müssen PHP für die Arbeit mit SSL konfigurieren

http://www.php.net/manual/en/openssl.installation.php

Ich hoffe, dass Sie Ihr Problem gelöst haben, jedoch für mich Zeile:

;extension=php_openssl.dll

existierte nicht in meiner php.ini (mit XAMPP 1.7.7 unter Win7), Fügen Sie es einfach im Abschnitt "Erweiterungen" hinzu, entfernen Sie das Semikolon und es sollte funktionieren.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top