PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Failed to connect to SMTP / socket error

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail
View previous topic :: View next topic  
Author Message
nickdrums



Joined: 30 Jan 2008
Posts: 4
Location: UK

PostPosted: Thu Jan 31, 2008 12:03 am    Post subject: Failed to connect to SMTP / socket error Reply with quote

Hi - trying to use Pear Mail for the first time, so it's possible I'm doing something silly ...

Every time I try to send an email I get the following error code :

Failed to connect to smtpauth.dsl.pipex.com:25 [SMTP: Failed to connect socket: Connection refused (code: -1, response: )]

The php code I am using is here:

require_once("Mail.php");

$recipients = '[email protected]';

$headers['From'] = '[email protected]';
$headers['To'] = '[email protected]';
$headers['Subject'] = 'Test message';

$body = 'Test message';

$params['host'] = 'smtpauth.dsl.pipex.com';
$params['port'] = '25';
$params['auth'] = true;
$params['username'] = '*** user ***';
$params['password'] = '*** pass ***';

// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', $params);

$send = $mail_object->send($recipients, $headers, $body);
if (PEAR::isError($send)) { print($send->getMessage());}

I can't seem to find any reference source to help me understand the -1 error code.

Any help greatly appreciated!

Nick.
Back to top
View user's profile Send private message
scilskitsios



Joined: 12 Feb 2008
Posts: 1

PostPosted: Tue Feb 12, 2008 5:27 pm    Post subject: Reply with quote

have you tried sending this without specifying a smtp server or is it necessary to use the smtp server you have mentioned.

My code looks like this:

$crlf = "\n";
$subject = "SUBJECT";
$hdrs = array(
'From' => '[email protected]',
'Subject' => $subject
'Reply-To' => '[email protected]'
);
$mail = new Mail_mime($crlf);
$mail->setTXTBody($emailText);
$mail->setHTMLBody($emailHtml);
$body = $mail->get();
$hdrs = $mail->headers($hdrs);
$mail =& Mail::factory('mail');
$mail->send($emailToSendTo, $hdrs, $body);
Back to top
View user's profile Send private message
nickdrums



Joined: 30 Jan 2008
Posts: 4
Location: UK

PostPosted: Thu Feb 14, 2008 12:58 am    Post subject: Reply with quote

Thanks for your reply. Yes, maybe that got lost in the detail - the whole point of this is that I am trying to use PEAR Mail as an alternative to PHP mail() as the former supports SMTP as a backend, as my (legitimate) volume emails are getting spammed out by Hotmail etc. when I use sendmail.
Back to top
View user's profile Send private message
sommertime



Joined: 13 Mar 2009
Posts: 2

PostPosted: Fri Mar 13, 2009 9:02 am    Post subject: Same Problem Reply with quote

Hello,

I am getting the same error, did anyone find a solution?

Thanks
Back to top
View user's profile Send private message
nickdrums



Joined: 30 Jan 2008
Posts: 4
Location: UK

PostPosted: Sat Mar 14, 2009 4:13 pm    Post subject: Reply with quote

No - this is one of the few I have given up on. I think the issue is trying to address an SMTP server which is remote from the webserver the script is running on, even with the correct credentials.

In my case, my web hoster finally seems to have got itself off the blacklists of hotmail etc., so I have continued to use sendmail.
Back to top
View user's profile Send private message
sommertime



Joined: 13 Mar 2009
Posts: 2

PostPosted: Sat Mar 14, 2009 8:51 pm    Post subject: sendmail Reply with quote

Yeah, I did the same thing. Thanks for the reply. You have to love the great support from others. LOL I will do my best to tell people not to use this code at all.
Back to top
View user's profile Send private message
nickdrums



Joined: 30 Jan 2008
Posts: 4
Location: UK

PostPosted: Sat Mar 14, 2009 9:32 pm    Post subject: Reply with quote

Oh I wouldn't say that. The PEAR code is excellent, it's more the security setup of my web hoster's mail server.

N.
Back to top
View user's profile Send private message
Heaven32



Joined: 24 Sep 2010
Posts: 1

PostPosted: Fri Sep 24, 2010 9:10 am    Post subject: Reply with quote

Thanks for you information i newly join and your post help me.
_________________
Heaven
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement