Error upgrading from ver 3 to ver 4

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
jerry27615
Forum Newbie
Posts: 2
Joined: Thu Oct 29, 2009 10:53 am

Error upgrading from ver 3 to ver 4

Post by jerry27615 »

I am trying to upgrade from Swift Mailer 3 to ver 4 and am havding trouble with code chages. I am getting the following error: Fatal error: Call to a member function embed() on a non-object in /hhhh/wwww/public_html/aaaa/swifttest.php on line 13

The program that causes this is:
<?php /* Created on: 10/29/2009 */ ?>
<html>
<body>
<?php
require_once "swift4/swift_required.php";
require_once "swift4/classes/Swift/SmtpTransport.php";
$transport = Swift_SmtpTransport::newInstance('smtp.myDomain.org', 25);
$transport ->setUsername('jjj@myDomain.org');
$transport ->setPassword('xxxx');
$mailer = Swift_Mailer::newInstance($transport);

$cid = $message->embed(Swift_EmbeddedFile::fromPath('../images/logo-s.jpg'));
$message = Swift_Message::newInstance();
$message ->setSubject('test of Swift4');

$message ->setFrom('jjj@myDomain.org');
$message ->setTo('jjj@myDomain.org');


$message->setBody('Here is the message itself'.$cid);


$result = $mailer->send($message);


?>
</body>
</html>
Last edited by jerry27615 on Thu Oct 29, 2009 1:02 pm, edited 1 time in total.
jerry27615
Forum Newbie
Posts: 2
Joined: Thu Oct 29, 2009 10:53 am

Re: Error upgrading from ver 3 to ver 4

Post by jerry27615 »

This is fixed, found the problem embed was out of sequence.
Post Reply