Page 1 of 1

External SMTP server

Posted: Thu Aug 23, 2007 2:41 pm
by gregjarvis
Hey everyone,
I cannot seem to connect to my external SMTP server. Here is the code I'm using:

Code: Select all

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("mail.midstatemutual.com");
$conn->attachAuthenticator(new Swift_Authenticator_LOGIN());
$swift =& new Swift($conn);
$smtp->setUsername("user_hidden");
$smtp->setpassword("pass_hidden");

$swift =& new Swift($smtp);
if ($swift->send($message, "gregj@midstatemutual.com", "admin@midstatemutual.com")) echo "Sent";
        else echo "Failed";

Posted: Thu Aug 23, 2007 4:05 pm
by mikesmith76
I didn't write the library (i'm sure the author will be around shortly) but noticed a few things:

- where does $smtp come from?
- why are you creating two instances of swift?

Posted: Thu Aug 23, 2007 6:16 pm
by Chris Corbyn
mikesmith hit the nail on the head. $conn should be $smtp, or $smtp should be $conn.... $smtp just appears from nowhere in your code. Oh yah, and only create one Swift instance.

Code: Select all

$smtp =& new Swift_Connection_SMTP("mail.midstatemutual.com"); 
$smtp->attachAuthenticator(new Swift_Authenticator_LOGIN()); 
$smtp->setUsername("user_hidden"); 
$smtp->setpassword("pass_hidden"); 

$swift =& new Swift($smtp);

question

Posted: Wed Sep 05, 2007 1:33 am
by jcbodyworks
now, I am trying to use an external SMTP as well, with this following code:

$smtp =& new Swift_Connection_SMTP("smtpout.secureserver.net", 80);
$smtp->setUsername("USER_HIDDEN");
$smtp->setpassword("PASSWORD_HIDDEN");

$swift =& new Swift($smtp);


I am fairly new to php and such, where exactly do I copy this code into so that my siftmailer can use this SMTP? And with the particular file in mind, where in the file do I place it? Thanks!


-Chris

Re: question

Posted: Wed Sep 05, 2007 9:20 am
by Chris Corbyn
jcbodyworks wrote:now, I am trying to use an external SMTP as well, with this following code:

$smtp =& new Swift_Connection_SMTP("smtpout.secureserver.net", 80);
$smtp->setUsername("USER_HIDDEN");
$smtp->setpassword("PASSWORD_HIDDEN");

$swift =& new Swift($smtp);


I am fairly new to php and such, where exactly do I copy this code into so that my siftmailer can use this SMTP? And with the particular file in mind, where in the file do I place it? Thanks!


-Chris
I highly doubt you should be using port 80 to connect to a SMTP server ;) Port 80 is the HTTP port. Ports 25, 465 and 587 are SMTP ports -- usually just 25.