failed with the first example - please help

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
wodka
Forum Newbie
Posts: 4
Joined: Wed Feb 25, 2009 7:36 pm

failed with the first example - please help

Post by wodka »

I tried the example provided in the readme, but it fails for me. I used version 3 on many projects, I love it! At first glance version 4 seems to be very cool, neat n clear syntax. Grat!
I'm moving all my sites to a new server (with fastcgi), and this caused problems with ver3. I'd like to switch to ver4.

This is the error I get. See my code below.

FastCGI: server "/usr/php5fcgi/bin/php-cgi-suhosin" stderr: PHP Catchable fatal error: Argument 1 passed to Swift_Transport_EsmtpTransport::__construct() must implement interface Swift_Transport_IoBuffer, none given in /data/domains/ossejtterapia.hu/web/webroot/swift/lib/classes/Swift/Transport/EsmtpTransport.php on line 74



require_once 'swift/lib/swift_required.php';



$smtp = Swift_SmtpTransport::newInstance('smtp.myserver.net', 25)
->setUsername('...')
->setPassword('...');

$mailer = Swift_Mailer::newInstance($smtp);

$message = Swift_Message::newInstance('Your subject');

$message->setTo('balho@wer.net')
->setFrom('mai@osse.hu')
->setBody(
'Here is an image ',
'text/html'
)
->addPart('This is the alternative part','text/plain')
;

if ($mailer->send($message))
{echo "Message sent!";
}
else
{echo "Message could not be sent.";
}

What am I doing wrong?
Thanks in advance,
Balazs
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: failed with the first example - please help

Post by Chris Corbyn »

Hi wodka,

That sounds like a really critical error. The dependency injector (something you need not concern yourself with) is not passing an object for the I/O Buffer that the SmtpTransport needs.

Can you post your PHP version? This is really important if I am to try to reproduce the error.

Also, have you modified the files under lib/dependency_maps/ in any way? Or any other files for that matter?

What happens if you open the test-suite/index.php file in your browser and run the tests?
wodka
Forum Newbie
Posts: 4
Joined: Wed Feb 25, 2009 7:36 pm

Re: failed with the first example - please help

Post by wodka »

PHP 5.2.8, Fastcgi

No, I didn't modify anything in any way.

I sent you the test-suite link, and phpinfo link in PM.

Many thanks!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: failed with the first example - please help

Post by Chris Corbyn »

Ok, basically your PHP installation is set to run as if it's PHP4 instead of PHP5.

I'm afraid I can't really support this.

From Zend Developer Zone:
zend.ze1_compatibility_mode boolean

Enable compatibility mode with Zend Engine 1 (PHP 4). It affects the cloning, casting (objects with no properties cast to FALSE or 0), and comparing of objects. In this mode, objects are passed by value instead of reference by default.
Can you try adding this line before your "require_once 'lib/swift_required.php';" line?

Code: Select all

<?php
 
ini_set('zend.ze1_compatibility_mode', false);
 
require_once 'lib/swift_required.php';
I can't add this to my own code since doing so modifies the global behaviour of PHP for the duration of the request. I'm not even sure it'll be ini_set() modifiable in this way. I'd strongly suggest editing php.ini to turn this mode off.
Post Reply