Swift 4.0 smtp authentication problems

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
sgardner
Forum Newbie
Posts: 2
Joined: Tue Mar 10, 2009 1:33 pm

Swift 4.0 smtp authentication problems

Post by sgardner »

I'm using the following syntax in my code

$transport = Swift_SmtpTransport::newInstance()
->setHost('mail.xxxxx.xxx')
->setPort(25)
->setUsername('xxxxxxx')
->setPassword('xxxxxx')
;

$mailer = new Swift_Mailer(new Swift_SmtpTransport($transport));

I receive the following errors

PHP Warning: fsockopen() expects parameter 1 to be string, object given in /lib/classes/Swift/Transport/StreamBuffer.php on line 244

PHP Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host Object id #3 [ #]'
BrandonMUS
Forum Newbie
Posts: 15
Joined: Mon Nov 10, 2008 9:45 am

Re: Swift 4.0 smtp authentication problems

Post by BrandonMUS »

You're wrapping the Transport in another Transport. Try this:

Code: Select all

$transport = Swift_SmtpTransport::newInstance()
->setHost('mail.xxxxx.xxx')
->setPort(25)
->setUsername('xxxxxxx')
->setPassword('xxxxxx')
;
 
$mailer = new Swift_Mailer($transport);
sgardner
Forum Newbie
Posts: 2
Joined: Tue Mar 10, 2009 1:33 pm

Re: Swift 4.0 smtp authentication problems

Post by sgardner »

BrandonMUS wrote:You're wrapping the Transport in another Transport. Try this:

Code: Select all

$transport = Swift_SmtpTransport::newInstance()
->setHost('mail.xxxxx.xxx')
->setPort(25)
->setUsername('xxxxxxx')
->setPassword('xxxxxx')
;
 
$mailer = new Swift_Mailer($transport);

DOH!
That did the trick thanks!
Post Reply