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: 2
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 = 'nick@cole2.com';

$headers['From'] = 'nick@drumsense.com';
$headers['To'] = 'nick@cole2.com';
$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' => 'do_not_reply@MYDOMAIN.COM',
'Subject' => $subject
'Reply-To' => 'webmaster@MYDOMAIN.COM'
);
$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: 2
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
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

'Actiemonitor' online projectmanagement software