Page 1 of 1

two questions; about: connections and message source

Posted: Sat May 03, 2008 3:03 am
by afwt
I have two questions I got stuck on:

1. Is there an easy way to somehow test the connection without sending an email? Something like trying to connect, then disconnecting and returning true or something...

2. Is there a way (probably to write a new "connection" object) to have Swift return a complete assembled source code instead of sending an email?

Thanks in advance.

Re: two questions; about: connections and message source

Posted: Sun May 04, 2008 12:14 am
by Chris Corbyn
afwt wrote:1. Is there an easy way to somehow test the connection without sending an email? Something like trying to connect, then disconnecting and returning true or something...
PHP 5:

Code: Select all

try {
  $swift = new Swift($connection);
  $swift->disconnect();
  echo "Connection works fine...";
} catch (Swift_ConnectionException $e) {
  echo "Connection doesn't work";
}
2. Is there a way (probably to write a new "connection" object) to have Swift return a complete assembled source code instead of sending an email?

Code: Select all

echo $message->build()->readFull();
That will be missing the To: and From: headers before send() is called, but you can do this:

Code: Select all

$message->setTo('an@address.com');
$message->setFrom('your@address.com');
 
echo $message->build()->readFull();