得到以下错误:
SMTP -> ERROR: Failed to connect to server: PHP_network_getaddresses: getaddrinfo Failed: No such host is known. (0)
SMTP Error: Could not connect to SMTP host. There was a problem sending this mail!
这是我的配置文件设置,因为我遵循了这个PHPMailer tutorial
// Configuration settings for My Site // Email Settings $site['from_name'] = 'Manish Dekavadiya'; // from email name $site['from_email'] = 'manish@<my-domain>.com'; // from email address // Just in case we need to relay to a different server,// provide an option to use external mail server. $site['smtp_mode'] = 'enabled'; // enabled or disabled $site['smtp_host'] = "smtp.<my-domain>.com"; $site['smtp_port'] = 587; $site['smtp_username'] = "manish@<my-domain>.com"; $site['smtp_password']="<password>";
并使用了mailer类和教程中提到的扩展类如下:
/*****sendmail.PHP****/
// Grab our config settings require_once($_SERVER['DOCUMENT_ROOT'].'/config.PHP'); // Grab the FreakMailer class //echo $_SERVER['DOCUMENT_ROOT']; require_once($_SERVER['DOCUMENT_ROOT'].'/lib/MailClass.inc'); // instantiate the class $mailer = new FreakMailer(); // Set the subject $mailer->Subject = 'This is a test'; $mailer->SMTPDebug = 1; // Body $mailer->Body = 'This is a test of my mail system!'; // Add an address to send to. $mailer->AddAddress('manish.dekavadiya@gmail.com','Manish Dekavadiya'); if(!$mailer->Send()) { echo 'There was a problem sending this mail!'; } else { echo 'Mail sent!'; } $mailer->ClearAddresses(); $mailer->ClearAttachments();
当我尝试在PHPmailer docs @ examples / test_smtp_gmail_basic.PHP中给出的示例时,还会出现另一个错误
SMTP -> ERROR: Failed to connect toserver: PHP_network_getaddresses:
getaddrinfo Failed: No such host is
known. (0) SMTP Error: Could not
connect to SMTP host. There was a
problem sending this mail!