Page 1 of 1

Install

Posted: Tue Apr 17, 2007 10:39 pm
by pinehead18
Ok this is the code i i have on a send email page.

Code: Select all

require_once "swift/lib/swift/Swift.php";
require_once "swift/lib/Swift/Connection/SMTP.php";
 
$swift =& new Swift(new Swift_Connection_SMTP("server.tld", 25));
 
$message =& new Swift_Message("Some subject", "Your message <u>here</u>", "text/html");
 
if ($swift->send($message, "recipient@domain.tld", "you@home.tld"))
{
    echo "Message sent";
}
else
{
    echo "Message failed to send";
}
however, if you look at the require, there is no swift.php inside the swift folder, even though thats what was specified by the docs on swiftmailer.org
which results in this error

Warning: main(swift/lib/swift/Swift.php) [function.main]: failed to open stream: No such file or directory in /home/pinehead/www/dennis/new/send.php on line 7

Fatal error: main() [function.require]: Failed opening required 'swift/lib/swift/Swift.php' (include_path='.:/usr/local/share/pear:/usr/local/lib/php') in /home/pinehead/www/dennis/new/send.php on line 7

So what I did was i found swift.php inside of lib/swift.php and changed it to that and i got this error message



atal error: Uncaught exception 'Swift_Connection_Exception' with message 'The SMTP connection failed to start [server.tld:25]: fsockopen returned Error Number -1220158082 and Error String ''' in /home/pinehead/www/dennis/new/swift/lib/Swift/Connection/SMTP.php:291 Stack trace: #0 /home/pinehead/www/dennis/new/swift/lib/Swift.php(220): Swift_Connection_SMTP->start() #1 /home/pinehead/www/dennis/new/swift/lib/Swift.php(97): Swift->connect() #2 /home/pinehead/www/dennis/new/send.php(10): Swift->__construct(Object(Swift_Connection_SMTP)) #3 {main} thrown in /home/pinehead/www/dennis/new/swift/lib/Swift/Connection/SMTP.php on line 291



Thanks.

Anthony

Posted: Wed Apr 18, 2007 12:51 am
by Chris Corbyn
Wrong path:

Code: Select all

require_once "swift/lib/Swift.php";
The rule is that for a class name of Foo_Bar you just turn the "_" to "/" and look for the file in that directory below lib (lib/Foo/Bar.php).

Swift => lib/Swift.php
Swift_Connection_SMTP => lib/Swift/Connection/SMTP.php

Posted: Wed Apr 18, 2007 1:36 am
by pinehead18
are you suggesting to change the require to the class?

else i don't see those class settings on the main code above.

thanks

Posted: Wed Apr 18, 2007 2:54 am
by Chris Corbyn
Yes, change the path in your require to what I just posted. That's where the error is coming from.

Posted: Wed Apr 18, 2007 5:58 pm
by pinehead18
I changed the paths too..


require_once "swift/lib/Swift.php";
require_once "swift/lib/Swift/Connection/SMTP.php";

inside my root directory, to get to lib you have to go through swift first.
Suggestions?






and i got this.
Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'The SMTP connection failed to start [server.tld:25]: fsockopen returned Error Number -1220158082 and Error String ''' in /home/pinehead/www/dennis/new/swift/lib/Swift/Connection/SMTP.php:291 Stack trace: #0 /home/pinehead/www/dennis/new/swift/lib/Swift.php(220): Swift_Connection_SMTP->start() #1 /home/pinehead/www/dennis/new/swift/lib/Swift.php(97): Swift->connect() #2 /home/pinehead/www/dennis/new/send.php(10): Swift->__construct(Object(Swift_Connection_SMTP)) #3 {main} thrown in /home/pinehead/www/dennis/new/swift/lib/Swift/Connection/SMTP.php on line 291

Posted: Thu Apr 19, 2007 12:43 am
by Chris Corbyn
Looks like a PHP bug :? That error number is a little suspicious. Swift uses a PHP function called fsockopen(). That's where that error is coming from. It's not something I'll be able to fix for you unfortunately other than asking you to try a different PHP installation.

EDIT | It says "server.tld" in the error message. You didn't actually try to connect to a server called server.tld right?

Posted: Thu Apr 19, 2007 6:06 pm
by pinehead18
giggity, i thought server.tld was the settings file for.

I change server.tld to the actual smtp server correct?

Where do i set the user name and password?

I read the docs, but didn't see..
Maby it was just up to late?

Posted: Thu Apr 19, 2007 6:08 pm
by John Cartwright
This post sais it better than I can

Posted: Thu Apr 19, 2007 6:32 pm
by nickvd

Code: Select all

require_once "swift/lib/swift/Swift.php";
require_once "swift/lib/Swift/Connection/SMTP.php";
"lib/swift" is not the same as "lib/Swift" ...