Page 1 of 1

Getting it to work

Posted: Sat Nov 15, 2008 6:45 pm
by billybob
I'm a newbie at php, have been able to get
the data side of my site running, however less
success with email side, tried PEAR and then
came across swift.

Here is my (actually your code- thank you!) code:

<?php
//Load in the files we'll need
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
require_once "lib/Swift/Authenticator/LOGIN.php";

// used the correct smtp, username, and password for runtime
$smtp =& new Swift_Connection_SMTP("smtp.myprovider.net");
$smtp->setUsername("user");
$smtp->setPassword("pass");
$smtp->attachAuthenticator(new Swift_Authenticator_LOGIN());

$swift =& new Swift($smtp);

//Create the message
$message =& new Swift_Message("My subject", "My body");

//Now check if Swift actually sends it
if ($swift->send($message, "charles_bristoll@centum.ca", "bristoll@trigger.net")) echo "Sent";
else echo "Failed";

?>

Here is the error message:

Fatal error: Uncaught exception 'Swift_ConnectionException' with message 'The SMTP connection failed to start [smtp.trigger.net:25]: fsockopen returned Error Number 10060 and Error String 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. '' in C:\Program Files\wamp\www\lib\Swift\Connection\SMTP.php:309 Stack trace: #0 C:\Program Files\wamp\www\lib\Swift.php(216): Swift_Connection_SMTP->start() #1 C:\Program Files\wamp\www\lib\Swift.php(101): Swift->connect() #2 C:\Program Files\wamp\www\emailtest.php(23): Swift->__construct(Object(Swift_Connection_SMTP)) #3 {main} thrown in C:\Program Files\wamp\www\lib\Swift\Connection\SMTP.php on line 309

I can't seem to figure out why it is not connecting.

Thank you! :banghead:

Re: Getting it to work

Posted: Thu Nov 20, 2008 4:46 am
by novice4eva

Re: Getting it to work

Posted: Thu Nov 20, 2008 9:54 pm
by novice4eva
I think the underlying cause is the same, i assume that you are working in your own console(localhost). But i believe if you are connected to the net you should still be able to send mails, provided that you have set the smtp correctly. Sorry i have not used swiftmailer yet but seems like everybody around prefers it so i will use it too soon(hopefully :D )..Is this "smtp.myprovider.net" running, it must not be replying back!! There must be some way to check that....
Let's see what turns up with this:

Code: Select all

 
$log =& Swift_LogContainer::getLog();
$log->setLogLevel(4);
 

Re: Getting it to work

Posted: Thu Nov 20, 2008 10:55 pm
by billybob
Got it to work.

checked with my ISP docs and said to use port 587 if 25 was blocked.

Thanks to novice4eva for pointing me in the right direction.

Awesome!!