Znalazłem gotowy skrytp do wysyłania maili, bo myślałem że mój już coś nie tak.
http://www.swiftmailer.org/ <?php
require('Swift.php');
require('Swift/Swift_SMTP_Connection.php');
//The mailer will now establish a connection with the server
$mailer = new Swift(new Swift_SMTP_Connection('smtp.googlemail.com', 465, SWIFT_TLS));
//If anything goes wrong you can see what happened in the logs
if (!$mailer->hasFailed()) //Optional
{
//You can call authenticate() anywhere before calling send()
if ($mailer->authenticate('mojmail@gmail.com', 'haslo'))
{
//Sends a simple email
$mailer->send(
'"Joe Bloggs" <joe@bloggs.com>',
'"yaro" <mojmail@gmail.com>',
'Hej',
"Działa?"
);
}
else echo "Didn't authenticate to server";
//Closes cleanly... works without this but it's not as polite.
$mailer->close();
}
else echo "The mailer failed to connect. Errors: ".print_r($mailer->errors, 1).". Log: ".print_r($mailer->transactions, 1
);
?>
i dostaje o to taki komunikat:
Kod
The mailer failed to connect. Errors: Array ( [0] => Array ( [num] => 0 [time] => 0.78746300 1153309469 [message] => Connection to the given MTA failed. The Connection Interface said: Unknown error: 0 ) ) . Log: Array ( )
Robie tak jak jest w przykładach i lipa.
Port też zmieniałem