我在我的本地机器上尝试了下面的代码,它工作正常,但是当我在雅虎小型企业上托管它时,它一直给出“SMTP connect() failed”。我能做些什么?
$mail = new PHPMailer();
$body = $message;
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.bizmail.yahoo.com"; //Outgoing mail (SMTP) server
$mail->Port = 465;
$mail->Username = "myadminmail@mydomain.net";
$mail->Password = "mypassword";
$mail->SMTPSecure = 'tls';
$mail->SetFrom('myadminmail@mydomain.net', 'name',false);
$mail->Subject = $subject;
$mail->AltBody = "Any message.";
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $name);
if(!$mail->Send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Mailer Sent: ' ;
}