Connection refused & undefined method

struggling PHP4-to-PHP5 newbie:
Errors in script testing viability of phpmailer.php ver.5.0.4 :

PHP Warning: fsockopen(): unable to connect to smtp.u-sit.net:25 (Connection refused) in /home/vg011web00/68/65/2926568/web/tstJan2013/class.smtp.php on line 107
PHP Fatal error: Call to undefined method SMTP::getError() in /home/vg011web00/68/65/2926568/web/tstJan2013/class.phpmailer.php on line 1923

Here’s the script.

[php]<?php #P2_tstphpmailer.php
#source: http://phpmailer.worxware.com/index.php?pg=tutorial

require(“class.phpmailer.php”);

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = “smtp.u-sit.net”;

$mail->From = "[email protected]";
$mail->AddAddress("[email protected]");

$mail->Subject = “First PHPMailer Message”;
$mail->Body = “Hi! \n\n This is my first e-mail sent through PHPMailer.”;
$mail->WordWrap = 50;

if(!$mail->Send()) {
echo ‘Message was not sent.’;
echo 'Mailer error: ’ . $mail->ErrorInfo;
} else {
echo ‘Message has been sent.’;
}
?>
[/php]

  1. Can’t understand why fsockopen() is trying to connect to smtp.u-sit.net:25 (?)
    $host is set to ‘smtp.u-sit.net’ on Line 31 of class.smtp.php
    and $port is set to ‘587’ (not 25) on Line 30.

  2. Have been lost some hours trying to understand class.phpmailer.php code
    especially the method throwing the udefined method error. It follows:

[php]#Lines 1920 – 1927:
protected function SetError($msg) {
$this->error_count++;
if ($this->Mailer == ‘smtp’ and !is_null($this->smtp)) {
$lasterror = $this->smtp->getError(); #L 1923
if (!empty($lasterror) and array_key_exists(‘smtp_msg’, $lasterror)) {
$msg .= ‘

’ . $this->Lang(‘smtp_error’) . $lasterror[‘smtp_msg’] . “

\n”;
}
}
$this->ErrorInfo = $msg;
}
[/php]

Any ideas will be apreciated.

usit

OK I fixed Connection refused – caused by inappropriate authentication.
But can’t understand what to do about undefined method that occurs on L. 1923 of class.phpmailer.php.
It occurs in a protected function (the following)
[php]protected function SetError($msg) {
$this->error_count++;
if ($this->Mailer == ‘smtp’ and !is_null($this->smtp)) {
$lasterror = $this->smtp->getError(); #<-- L. 1923
if (!empty($lasterror) and array_key_exists(‘smtp_msg’, $lasterror)) {
$msg .= ‘

’ . $this->Lang(‘smtp_error’) . $lasterror[‘smtp_msg’] . “

\n”;
}
}
$this->ErrorInfo = $msg;
}[/php]
This line fails apparently because ‘getError()’ is not found anywhere in the entire script, nor is ‘geterror()’.
Is this an oversight in the original class.phpmailer.php script? Whateve the case, how do I get around it?
Help greatly appreciated.

Thanks
usit

Getting closer.
Web search turned up suggested solution requiring class.smtp.5.0.1.php for class.phpmailer.php5.

I find lots of links to downloads for smtp.php but on arrival at the url there are no active downloads available.
Can anyone point to a source for class.smtpl5.0.1.php?

Thanks
usit

Sponsor our Newsletter | Privacy Policy | Terms of Service