pop3 error?

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
dan bloch
Forum Newbie
Posts: 7
Joined: Wed Aug 08, 2007 12:50 pm

pop3 error?

Post by dan bloch »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello! 

I am excited to get the swiftmailer up as soon as possible and have run into a problem.

My knowledge of network communications and their principles is less than weak so please forgive my lack of understanding in this matter.  I am just starting to test swift and am using WAMP XP-Apache2-mysql5-php5.  when I run my routine I get the following error.

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

I have an account with qwest and that gives me an account with msn as the mail provider.
I am using qwest supplied values for the hostName, port, logon and password.  These are the same values in the outlook tools -  email account screens.  

The only difference between the outlook email account screens and Swift is that I have seen no mention of a place for the pop3 address?   It probably doesnt even matter?

I did a telnet smt.xxxx.com 995 and it 'could not open connection to host on port 995....

I also did a ping and it wouldn't work.

THe code is as follows:

Code: Select all

<?php

	require_once ("SwiftMailer/lib/Swift.php")  ;
	require_once ("SwiftMailer/lib/Swift/Connection/SMTP.php");
	require_once ("SwiftMailer/lib/Swift/Authenticator/$PopB4Smtp$.php") ;



//	Start Swift	------------------------------------------------------
//	Lang.	new Swift_Connection_SMTP(string remote_host[, int remote_port [, int encryption_level]]) 

	$smtp 	=	new Swift_Connection_SMTP( $Institution_SMTP_host_name , $Institution_SMTP_host_Port );
	
	//Load the PopB4Smtp authenticator with the pop3 hostname
	$smtp->attachAuthenticator(new Swift_Authenticator_PopB4Smtp("pop.host.tld"));

	//Continue like normal
	$smtp->setUsername( $Institution_SMTP_host_userName );
	$smtp->setPassword( $Institution_SMTP_host_pwd );
	
 
	$swift 	= new Swift($smtp);


	//	Create the instance and Subject	--------SUBJECT--------------
	$message 	=  new Swift_Message("Billing for ".date("F-Y" )   );

		//	Attach the message part
		$message->attach(new Swift_Message_Part( "Your Statement for ".date("F-Y" )." is attached to this email as a PDF file."    ));
 
		//	Make the attachment with the Swift_File class
		//	Swift_Message_Attachment __construct 
		//	([mixed $data = null], [string $name = null], [string $type = "application/octet-stream"], [string $encoding = "base64"], [ $disposition = "attachment"]) 

		//	By using Swift_File you save memory by not having the file contents in memory, and by not having such a large overhead 
		//	in encoding. This is the preferred method for attaching large files. 

		

		//	Additionally, using Swift_File allows you to leave out the filename parameter 
		//	in Swift_Message_Attachment since it provides the filename itself. 
		//	$message->attach(new Swift_Message_Attachment(  new Swift_File(  "INC/Statements/".$PDF_Filename   ), $PDF_Filename , "application/pdf"));
	
		//	$message->attach(new Swift_Message_Attachment(  new Swift_File(  "INC/Statements/".$PDF_Filename   ),  , "application/pdf"));
		
		$message->attach(new Swift_Message_Attachment(  new Swift_File(  "INC/Statements/".$PDF_Filename   )));


 
		//	Send it out
		//	$swift->send($message, "my-friend@host.tld", "me@my-domain.tld");
		//	$sent	returns the number of records sent
		//	recipients-----> email and Name-----along with----->  Senders email and Name   
		$From     		=	$InstitutionDepartmentEmail    ;
		$FromName 		=	$InstitutionName."  ".$InstitutionDepartmentName ;
		
		
	$sent = $swift->send( $message  , new Swift_Address(  $Department_email ), new Swift_Address( $From  ,  $FromName  ));

		
?>
Where do I need to focus my efforts?

Thank you for sharing your time with me.

Dan Bloch


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?php
    echo "sorry about that tag issue, I'm a newbie";
?>
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

fsockopen() is throwing that error out rather than PHP ;) Your PHP installation seems to be refusing connections to the outside world.

By the way, if Pop3 is actually needed this should be throwing an error:

Code: Select all

require_once ("SwiftMailer/lib/Swift/Authenticator/$PopB4Smtp$.php") ;
The $ signs in it need escaping:

Code: Select all

require_once ("SwiftMailer/lib/Swift/Authenticator/\$PopB4Smtp\$.php") ;
Have you tried without the PopBeforeSmtp stuff?
dan bloch
Forum Newbie
Posts: 7
Joined: Wed Aug 08, 2007 12:50 pm

Post by dan bloch »

Thankyou for your prompt reply.

I have pasted in the

Code: Select all

require_once ("SwiftMailer/lib/Swift/Authenticator/\$PopB4Smtp\$.php") ;
with the escape codes as you have suggested. I have not tested yet.

The microsoft outlook tools-email account screen information as relayed by my chat line rep from qwest suggests:

Here are the steps to configure Outlook 2002/2003 for q.com e-mail:
1. Click "Tools"

2. Click "E-mail Accounts…"

3. Choose "Add A New E-mail Account"

4. Click "Next"

5. Choose "POP3"

6. Click "Next"

7. The Pop3 server is pop3.XXXX.com
and
The SMTP server is smtp.XXXX.com

It is for that reason that I thought I needed a pop3 account.

I just ran it and I got

Code: Select all

Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'The SMTP connection failed to start [smtp.live.com]: 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:\Apache\Apache2\WEB_Pages\INC\SwiftMailer\lib\Swift\Connection\SMTP.php:293 Stack trace: #0 C:\Apache\Apache2\WEB_Pages\INC\SwiftMailer\lib\Swift.php(225): Swift_Connection_SMTP->start() #1 C:\Apache\Apache2\WEB_Pages\INC\SwiftMailer\lib\Swift.php(102): Swift->connect() #2 C:\Apache\Apache2\WEB_Pages\INC\ar_DeptStatements_SwiftMailer.php(24): Swift->__construct(Object(Swift_Connection_SMTP)) #3 C:\Apache\Apache2\WEB_Pages\ar_DeptStatements_pdfAtch.php(144): include('C:\Apache\Apach...') #4 {main} thrown in C:\Apache\Apache2\WEB_Pages\INC\SwiftMailer\lib\Swift\Connection\SMTP.php on line 293



Thank You again for sharing your time with me

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

Post by Chris Corbyn »

I'm afraid I can't help you any more than re-wording that error message for you ;) Swift uses a PHP function called fsockopen(). fsockopen() is failing to connect to your server for whatever reason, or the connection is being made but no response is coming back. This could be down to a firewall or PHP permissions. It's also possible there's a bug with your version of PHP since the fsockopen() function has cropped up in the bugs list on php.net many a time. Not a lot else I can tell you I'm afraid.

If you're equally out of options try upgrading PHP and see what happens ;)
dan bloch
Forum Newbie
Posts: 7
Joined: Wed Aug 08, 2007 12:50 pm

Post by dan bloch »

G'day Sir,

I am a WAMP win - XP and as you have suggested.

I have upgraded from apache 2.0.55 to 2.0.59 and in php from 5.1.2 to 5.2.3. The original install was so long ago that I struggled for a bit.


I have the WAMP on a PC and am sending to domain host.

Code: Select all

<?php 

        require_once ("SwiftMailer/lib/Swift.php")  ; 
        require_once ("SwiftMailer/lib/Swift/Connection/SMTP.php"); 
 		require_once ("SwiftMailer/lib/Swift/Authenticator/\$PopB4Smtp\$.php") ;
 		
 		
//        require_once ("SwiftMailer/lib/Swift/Authenticator/$PopB4Smtp$.php") ; 



//      Start Swift   ------------------------------------------------------ 
//      Lang. new Swift_Connection_SMTP(string remote_host[, int remote_port [, int encryption_level]]) 

        $smtp   = new Swift_Connection_SMTP( $Institution_SMTP_host_name , $Institution_SMTP_host_Port ); 
        
        //Load the PopB4Smtp authenticator with the pop3 hostname 
        
        $smtp->attachAuthenticator(new Swift_Authenticator_PopB4Smtp( $Institution_SMTP_host_name )); 

        //Continue like normal 
        $smtp->setUsername( $Institution_SMTP_host_userName ); 
        $smtp->setPassword( $Institution_SMTP_host_pwd ); 
        
  
        $swift  = new Swift($smtp); 


        //      Create the instance and Subject       --------SUBJECT-------------- 
        $message        =  new Swift_Message("Billing for ".date("F-Y" )   ); 

                //      Attach the message part 
                $message->attach(new Swift_Message_Part( "Your Statement for ".date("F-Y" )." is attached to this email as a PDF file."    )); 
  
                //      Make the attachment with the Swift_File class 
                //      Swift_Message_Attachment __construct 
                //      ([mixed $data = null], [string $name = null], [string $type = "application/octet-stream"], [string $encoding = "base64"], [ $disposition = "attachment"]) 

                //      By using Swift_File you save memory by not having the file contents in memory, and by not having such a large overhead 
                //      in encoding. This is the preferred method for attaching large files. 

                

                //      Additionally, using Swift_File allows you to leave out the filename parameter 
                //      in Swift_Message_Attachment since it provides the filename itself. 
                //      $message->attach(new Swift_Message_Attachment(  new Swift_File(  "INC/Statements/".$PDF_Filename   ), $PDF_Filename , "application/pdf")); 
        
                //      $message->attach(new Swift_Message_Attachment(  new Swift_File(  "INC/Statements/".$PDF_Filename   ),  , "application/pdf")); 
                
                $message->attach(new Swift_Message_Attachment(  new Swift_File(  "INC/Statements/".$PDF_Filename   ))); 


  
                //      Send it out 
                //      $swift->send($message, "my-friend@host.tld", "me@my-domain.tld"); 
                //      $sent returns the number of records sent 
                //      recipients-----> email and Name-----along with----->  Senders email and Name    
                $From                 =     $InstitutionDepartmentEmail    ; 
                $FromName             =     $InstitutionName."  ".$InstitutionDepartmentName ; 
                
                
        $sent = $swift->send( $message  , new Swift_Address(  $Department_email ), new Swift_Address( $From  ,  $FromName  )); 
?>

I get--------------------------


Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'The SMTP connection failed to start [mail.academicresearchtechnologies.com:0]: fsockopen returned Error Number 0 and Error String 'Failed to parse address "mail.academicresearchtechnologies.com"'' in C:\Apache\Apache2\WEB_Pages\INC\SwiftMailer\lib\Swift\Connection\SMTP.php:293 Stack trace: #0 C:\Apache\Apache2\WEB_Pages\INC\SwiftMailer\lib\Swift.php(225): Swift_Connection_SMTP->start() #1 C:\Apache\Apache2\WEB_Pages\INC\SwiftMailer\lib\Swift.php(102): Swift->connect() #2 C:\Apache\Apache2\WEB_Pages\INC\ar_DeptStatements_SwiftMailer.php(26): Swift->__construct(Object(Swift_Connection_SMTP)) #3 C:\Apache\Apache2\WEB_Pages\ar_DeptStatements_pdfAtch.php(138): include('C:\Apache\Apach...') #4 {main} thrown in C:\Apache\Apache2\WEB_Pages\INC\SwiftMailer\lib\Swift\Connection\SMTP.php on line 293

Help!!!!


Thank you for your time


dan bloch
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 $Institution_SMTP_host_Port is zero from that error message?
dan bloch
Forum Newbie
Posts: 7
Joined: Wed Aug 08, 2007 12:50 pm

Post by dan bloch »

Yes, I changed it to 110 and the result is the same.

thank you

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

Post by Chris Corbyn »

The problem is not the pop3 port, it's the SMTP port (should be 25, but you're using 0). 110 is for Pop3.
Post Reply