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