Page 1 of 1

[SOLVED] setReturnPath not working in Swift-3.0.1-php4

Posted: Fri Mar 02, 2007 1:02 pm
by Kirk84
Thanks for this great script. Everything is working fine for me so far but now I have run into a problem.

When I try to use the function setReturnPath as below in Swift 3.0.1 with PHP 4.4.1 in a script that works fine otherwise I get:

Fatal error: Call to undefined function: setreturnpath()

Is the code below from version 2? How can I use setReturnPath in version 3? I see the function exists in Message.php but if I am supposed to do something else to use this in version 3 I can not figure out what.

Thanks,

Kirk
d11wtq wrote:The address in the From: header is the one you give to send(). The bounce-back address (Return-Path, and "MAIL FROM" envelope) is the one passed to $swift->setReturnPath($address), or otherwise, the same as the From: address.

I was going to post a link to the relevant page in the documentation, but now I see why this question crops up so regularly... I forgot to document it :roll:

Code: Select all

$swift = new Swift( ... );

$from = "your@address.com";
$bounce_detect = "bounces@address.com";

$swift->setReturnPath($bounce_detect);
//

$swift->send($from, $to, $subject, $message);

Posted: Fri Mar 02, 2007 3:36 pm
by Chris Corbyn
That's my slopiness, sorry. You can actually perform any of the methods laid out for Swift_Message and Swift by referring to $easyswift->message and $easyswift->swift. For example:

Code: Select all

$easyswift->message->setEncoding("iso-8859-2");

$easyswift->swift->send(....);
Those properties (message and swift) are actually instances of the version 3 API components, EasySwift simply wraps that API into the v2 API. I'll fix that problem in SVN. I'm making a new release soon as several similar minor bugfixes have been made, mostly in the PHP4 version branch.

Posted: Fri Mar 02, 2007 8:52 pm
by Kirk84
Thanks for the quick reply but I can't get setReturnPath to work with easyswift either. The script works fine until I add:

Code: Select all

$bounce_detect = "support@myserver.org";
$easyswift->swift->setReturnPath($bounce_detect);
With this I get:

Fatal error: Call to a member function on a non-object.

Am I missing something or does the function need to be fixed?

Thanks,

Kirk

Posted: Sat Mar 03, 2007 5:18 am
by Chris Corbyn

Code: Select all

$bounce_detect = "support@myserver.org"; 
$easyswift->message->setReturnPath($bounce_detect);

Posted: Sat Mar 03, 2007 10:08 am
by Chris Corbyn
Sorry, I'm an idiot, I assumed you were using EasySwift and I haven't forgotten to add that method, it is there. setReturnPath() DOES NOT exist in Swift though. You set it in the message itself.

Code: Select all

$message->setReturnPath(...);
EDIT | You really NEED to read the documentation if you're going from v2 to v3. It states quite clearly that v2 code won't just work in v3.

Posted: Sat Mar 03, 2007 2:06 pm
by Kirk84
I got it working! Thanks.

Since I have not used Swift before 3.01, Swift is actually easier for me than EasySwift although I could use either.

Code: Select all

$message->setReturnPath();
Because the function is in Message.php this is actually one of the first things I tried. The problem was I put it _before_ the line that creates the message :-/ I didn't actually stop to think that $message is actually - the message.

If you are an idiot I don't know what that makes me :-)

Thanks,

Kirk