External SMTP server

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
gregjarvis
Forum Newbie
Posts: 1
Joined: Thu Aug 23, 2007 2:37 pm

External SMTP server

Post 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";
mikesmith76
Forum Commoner
Posts: 34
Joined: Fri Aug 25, 2006 7:10 am
Location: Manchester, UK

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

Post 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);
jcbodyworks
Forum Newbie
Posts: 2
Joined: Wed Sep 05, 2007 1:29 am

question

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

Re: question

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