I am trying to send an email with swift mailer using Exchange authentication. However, I can't seem to figure out why it doesn't work.
<?php
require_once( "./application/helpers/swift/swift_required.php" );
$transport =
Swift_SmtpTransport::newInstance( "31.149.66.10", 25 )
->setUsername( "username" )
->setPassword( 'password' )
->setEncryption( "tls" );
$mailer = Swift_Mailer::newInstance( $transport );
$message = Swift_Message::newInstance( "onderwerp" )
->setFrom( array( "[email protected]" ) )
->setTo( array( "[email protected]" ) )
->setBody( "Body van het bericht" );
var_dump( $mailer->send( $message ) );
?>
This gives me the error: Uncaught exception 'Swift_TransportException' with message 'Failed to authenticate on SMTP server with username "nieuwsbrief" using 0 possible authenticators'.
The server is configured to use TLS and basic authentication (Offer Basic authentication only after starting TLS).
I saw that some people use port 587 for TLS encryption, but I can't connect on port 587. That gives the error: Connection could not be established with host 31.149.66.10 [No route to host #113].
Can anyone see what I'm doing wrong?