two questions; about: connections and message source

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
afwt
Forum Newbie
Posts: 15
Joined: Fri Sep 21, 2007 2:53 pm

two questions; about: connections and message source

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: two questions; about: connections and message source

Post 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();
Post Reply