Setting Up SwiftMailer on XP

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
OldHatt45
Forum Newbie
Posts: 4
Joined: Wed Feb 27, 2008 8:24 pm

Setting Up SwiftMailer on XP

Post by OldHatt45 »

Sorry, but I am likewise (as LeapFrog) feeling VERY Stupid.

I have set up my XP development machine to use php, mysql, IIS, etc.

I need to do some email stuff from a web site I'm building.
I followed what I belive arethe installation instructions but I can't seem to get the Smoke tests to run. Not sure what I've done wrong.

I would really appreciate some help in getting things set up and running.
I did change (or at least I think I did) the TestConfiguration.php file so that chris does not receive all my test mail ;-))

Anyhow even after reading the tutorials, I need a bit of a push in the right direction.

Thanks in Advance

OldHatt45
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Setting Up SwiftMailer on XP

Post by Chris Corbyn »

OldHatt45 wrote:Sorry, but I am likewise (as LeapFrog) feeling VERY Stupid.
Don't, my documentation could be a little clearer in places ;)
I followed what I belive arethe installation instructions but I can't seem to get the Smoke tests to run. Not sure what I've done wrong.
I'd have to see some error messages before I can help you any further really.
I did change (or at least I think I did) the TestConfiguration.php file so that chris does not receive all my test mail ;-))
I'm used to heaps of test mail coming through, but fortunately I've moved to new mail servers since then so the smtp server name in the smoke tests doesn't actually work anyway. You need to edit that to point to your own SMTP server.
OldHatt45
Forum Newbie
Posts: 4
Joined: Wed Feb 27, 2008 8:24 pm

Re: Setting Up SwiftMailer on XP

Post by OldHatt45 »

Chris,

OK, here is the output from the Smoke test I ran.

Code: Select all

 
Fatal error: Uncaught exception 'Swift_ConnectionException' with message 'The SMTP connection failed to start [localhost\DobeRescueAL\lib:25]: fsockopen returned Error Number 7465404 and Error String ''' in C:\Inetpub\wwwroot\DobeRescueAL\lib\Swift\Connection\SMTP.php:309 Stack trace: #0 C:\Inetpub\wwwroot\DobeRescueAL\lib\Swift.php(216): Swift_Connection_SMTP->start() #1 C:\Inetpub\wwwroot\DobeRescueAL\lib\Swift.php(101): Swift->connect() #2 C:\Inetpub\wwwroot\DobeRescueAL\SwiftMailTest.php(12): Swift->__construct(Object(Swift_Connection_SMTP)) #3 {main} thrown in C:\Inetpub\wwwroot\DobeRescueAL\lib\Swift\Connection\SMTP.php on line 309
 
And here is the Code that produced the output.

Code: Select all

 
 <?php            
        //Load in the files we'll need
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
 
        //check with your host what your smtp server is (if using smtp)     
        $smtp =& new Swift_Connection_SMTP("localhost\DobeRescueAL\lib"); 
        //$smtp =& new Swift_Connection_SMTP("smtp.myhost.com"); 
                        
        $smtp->setUsername("myacct1"); //Used one of my email accounts
        $smtp->setpassword("NotTelling");
        $swift = new Swift($smtp);
        
                $message =& new Swift_Message("Email Test", "This should be the Body Text");
        
        //recipients list
           $recipients = new Swift_RecipientList();
                
        $recipients->addTo("myacct2@mymail.com");  //My 2nd acct
        //$recipients->addTo("email1@somewhere.com]);
 
        //$recipients->addTo("email2@somewhere.com]);  //and you can go on adding
        
        
    
        // if ( $swift->batchSend($message, $recipients, "myadress@somewhere.com", "my name") ) 
        if ( $swift->batchSend($message, $recipients, "MyAcct1", "M Y Name") ) 
        {
            $swift->disconnect();
            echo "Email Sent Success";
            //header("location: newsletter.php?msg=sentsuccess");
        }
        else 
        {
            $swift->disconnect();
            echo "The email was not sent - Fail";
            //header("location: newsletter.php?msg=sentfail");
        }
?>
 
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Setting Up SwiftMailer on XP

Post by Zoxive »

Did you attempt and read the error message swift is giving you?

It couldn't connect to the SMTP server.
Most likely the host blocking your connection, and or a firewall.

Also.. the smtp server you specified looks fishy.

"localhost\DobeRescueAL\lib", normally its something along the lines of mail.myserver.com
OldHatt45
Forum Newbie
Posts: 4
Joined: Wed Feb 27, 2008 8:24 pm

Re: Setting Up SwiftMailer on XP

Post by OldHatt45 »

First, I am completely lost on this. Normally I'm pretty good if I can read the documentation, but (and I apologize for sounding critical) the documentation leaves a bit to be desired and I make no bones about the fact I am a Newbie.

I set everything up on my development machine (Windows XP Pro).

The "localhost" thing may look fishy, but yes I did mean to use "localhost", I didn't know what else to use. ;-)

I also did the changes in TestCOnfiguration.php
But again, I have limited knowledge of that.

Just trying to get this going so, if you can explain what and how this needs to be set up I'd really appreciate it. Once I get the code going on my machine then I should understand enough to move it and change it so it runs on the ISP server (Linus/Apache).

All I'm trying to do is send a confirmation email to 2 places. One copy to the person filling in a form on the web site and the other copy to the web site owner. This should be simple, but as we all know..................... ;-)

OldHatt45
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Setting Up SwiftMailer on XP

Post by Zoxive »

Localhost is fine for the server, but what I meant was.. what is "localhost\DobeRescueAL\lib"?

I'm not sure how everyone else tests mailing, but I always do it on the server side, so I don't have to go threw all the mess of setting a smtp server up on my machine.
OldHatt45
Forum Newbie
Posts: 4
Joined: Wed Feb 27, 2008 8:24 pm

Re: Setting Up SwiftMailer on XP

Post by OldHatt45 »

Well, "localhost\DobeRescueAL\lib" is equivalent to wwwroot which is the home directory of a default web site the rest is simply a directory structure under the "home directory".

SInce I have several web sites that I'm working on (all hosted by different ISP's) it's just not convenient to log in to all of them when I can set things up on my own machine, get them working and then upload to the appropriate ISP/Web site.

If you set up IIS on your own machine, one of the components you can choose to add is SMTP. Which I have done. I just need help sorting all the mailer stuff out. ;-)

THanks

OldHatt45
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Setting Up SwiftMailer on XP

Post by Weirdan »

OldHatt45 wrote: If you set up IIS on your own machine, one of the components you can choose to add is SMTP. Which I have done. I just need help sorting all the mailer stuff out. ;-)
Most probably you need just 'localhost' as your smtp server name. SMTP aren't accessed via filesystem, so no path is required.
Post Reply