尝试使用php发送发送电子邮件,上传到我的服务器的文件:timeoutfix.diff,smtp.inc.php,phpmailer.inc.php仍然没有发送邮件。 有人可以帮帮我吗?
HTML表单:
<form method="post" action="contactengine.php">
<label for="Name">Name:</label>
<input type="text" name="Name" id="Name" />
<label for="Company">Company:</label>
<input type="text" name="Company" id="Company" />
<label for="Email">Email:</label>
<input type="text" name="Email" id="Email" />
<label for="Message">Message:</label><br />
<textarea name="Message" rows="20" cols="20" id="Message"></textarea>
<input type="submit" name="submit" value="Submit" class="submit-button" />
</form>
php代码:
<?php
$Subject = "Email from test website";
$Name = Trim(stripslashes($_POST['Name']));
$Company = Trim(stripslashes($_POST['Company']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
require("phpmailer.inc.php");
$mail = new phpmailer;
$mail->IsSMTP(); // set mailer to use SMTP
$mail->From = "test@test.com";
$mail->FromName = " Gartner Israel";
$mail->Host = "62.219.91.15"; // specify main and backup server
$mail->AddAddress("myemail@gmail.com");
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Email from test website";
$mail->Body = $Body;
if ($mail->Send();){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>
答案 0 :(得分:0)
我认为这个问题与“来自”字段有关 - 大概是你没有自己的test.com?尝试删除它,并使用您的默认php发送服务器测试发送。如果可行,那么您可以考虑在那里使用更有用的地址。
答案 1 :(得分:0)
删除分号,我在检查条件中看到错误
if ($mail->Send();)