Page 1 of 1

attempting to use swiftmailer

Posted: Wed Jun 27, 2007 10:05 pm
by nomb
I'm attempting to use swiftmailer and get this error: Fatal error: Call to a member function setUsername() on a non-object in /var/www/scripts/test.php on line 9

Here is my code:

Code: Select all

<?php
 
//Load in the files we'll need
require_once "swift/lib/Swift.php";
require_once "swift/lib/Swift/Connection/SMTP.php";
require_once "swift/lib/Swift/Authenticator/LOGIN.php";
 
$conn =& new Swift_Connection_SMTP("smtp.xxxxxxxx.net");
$smtp->setUsername("xxxxxx");
$smtp->setpassword("xxxxxx");
$conn->attachAuthenticator(new Swift_Authenticator_LOGIN());
 
$swift =& new Swift($conn);
 
//Create the message

$name = $_POST["name"];
$email = $_POST["email"];

$body .= "Name: $name\n";
$body .= "Email: $email\n";
$body .= "\n";
$body .= $_POST["message"]; 

$message =& new Swift_Message("A new message from your website.", $body);
 
//Now check if Swift actually sends it
if ($swift->send($message, "webmaster@nombyte.com", "nomb85@comcast.net")) echo "Sent";
else echo "Failed";

?>
Thank you for any help.

nomb

Posted: Wed Jun 27, 2007 10:09 pm
by feyd
$conn vs $smtp... ;)

Posted: Wed Jun 27, 2007 10:11 pm
by nomb
Bah, [s]ur[/s] you're right. I must have been stairing at it too long... :D

I must say out of all the forums I've been a part of, you are by far the most helpful and quickest person ever.

Thanks for everything.

nomb
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.

Posted: Wed Jun 27, 2007 10:38 pm
by feyd
nomb wrote:I must say out of all the forums I've been a part of, you are by far the most helpful and quickest person ever.
Thanks. We try. :)