Could not access file: http://localhost/k/d/filename.pdf
2014-07-28 16:20:10 SMTP ERROR: Failed to connect to server: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
(10060) SMTP connect() failed. Mailer Error: SMTP connect() failed.
我正在尝试发送电子邮件。我正在使用XAMPP和PHPMailer,我不知道我做错了什么。我查了很多类似的问题,但我找不到我的错误。
require("PHPMailer/class.phpmailer.php");
require 'PHPMailer/class.smtp.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "username@gmail.com";
$mail->Password = "password";
$webmaster_email = "username@gmail.com";
$email=$_POST['email'];
$name=$_POST['email'];
$mail->From = "username@gmail.com";
$mail->FromName = "User Name";
$mail->AddAddress($_POST['email'],$_POST['email']);
$mail->AddReplyTo("username@gmail.com","User Name");
$mail->WordWrap = 50;
$mail->AddAttachment($_POST['file']);
$mail->IsHTML(true);
$mail->Subject = "sent document";
$mail->Body = "Here is the document you requested. Thank you.";
$mail->AltBody = "Here is the document you requested from myITpc. Thank you.";
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
$_POST['email']
包含一个电子邮件地址,例如joe.shmo@hotmail.com
和$_POST['file']
包含本地文件路径,例如http://localhost/folder/file.pdf
。
谢谢!