1
我想嘗試從本地主機發送我的Web應用程序的電子郵件。我正在使用SMTP Gmail。我在我的電腦上安裝了一個SMTP服務器,用於發送帶有this one的郵件。 我在我的控制器像下面的語法:PHPMailer已建立的連接被您主機中的軟件中止
Yii::import('application.extensions.PHPMailer.JPhpMailer');
$mail = new JPhpMailer;
$mail->IsSMTP();
$mail->Host = 'smpt.gmail.com:';
$mail->Posrt = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = 'myGmailAccount';
$mail->Password = 'myPassword';
$mail->SetFrom('$to', '$name');
$mail->Subject = 'PHPMailer Test Subject via smtp, basic with authentication';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML('<h1>JUST A TEST!</h1>');
//$mail->AddAddress('');
$mail->Send();
但錯誤發生:
SMTP -> ERROR: Failed to connect to server: The requested address is not valid in its context. (10049) SMTP Error: Could not connect to SMTP host.
如何解決呢?