Install

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
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Install

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

Post 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
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

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

Post by Chris Corbyn »

Yes, change the path in your require to what I just posted. That's where the error is coming from.
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

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

Post 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?
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

This post sais it better than I can
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post 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" ...
Post Reply