 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
nickdrums
Joined: 30 Jan 2008 Posts: 2 Location: UK
|
Posted: Thu Jan 31, 2008 12:03 am Post subject: Failed to connect to SMTP / socket error |
|
|
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 |
|
 |
scilskitsios
Joined: 12 Feb 2008 Posts: 1
|
Posted: Tue Feb 12, 2008 5:27 pm Post subject: |
|
|
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 |
|
 |
nickdrums
Joined: 30 Jan 2008 Posts: 2 Location: UK
|
Posted: Thu Feb 14, 2008 12:58 am Post subject: |
|
|
| 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 |
|
 |
|
|
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
|
|