Php mailer脚本在Apache托管的引导程序网站上不起作用

Php mailer脚本在Apache托管的引导程序网站上不起作用,php,apache,email,Php,Apache,Email,我正在创建一个简单的Django/Bootstrap网站,它托管在运行apache的VM上 我的网站路径是var/www/experience/ 我在创建php mailer联系人表单时遵循了这一点。但是运行sudo apt get install libapache2-mod-php5解决了这个问题 我还尝试了一个朋友给我的第二个脚本,他在几个网站上使用过它 我的问题是没有发送联系方式电子邮件。我已经用两个不同的电子邮件帐户检查了它,并且我已经检查了垃圾邮件文件夹,以防万一。正如我所说,我还检

我正在创建一个简单的Django/Bootstrap网站,它托管在运行apache的VM上

我的网站路径是var/www/experience/

我在创建php mailer联系人表单时遵循了这一点。但是运行
sudo apt get install libapache2-mod-php5解决了这个问题

我还尝试了一个朋友给我的第二个脚本,他在几个网站上使用过它

我的问题是没有发送联系方式电子邮件。我已经用两个不同的电子邮件帐户检查了它,并且我已经检查了垃圾邮件文件夹,以防万一。正如我所说,我还检查了两个单独的脚本

在我这方面,还有什么可能是错误的或需要更改/配置的

我的mailer.php文件位于var/www/experience/php这是正确的位置吗

有没有人可以链接到更好的php mailer和apache使用教程

编辑:添加代码

Bootstrap-HTML

<form name="contactform" method="post" action="http://location_of_my_web_app/php/mailer.php"class="form-horizontal" role="form">

<div class="form-group">
<label for="inputName" class="col-lg-2 control-label">Name</label>
    <div class="col-lg-10">
    <input type="text" class="form-control" id="inputName" name="inputName" placeholder="Your Name">
    </div>
</div>
<div class="form-group">
<label for="inputEmail1" class="col-lg-2 control-label">Email</label>
    <div class="col-lg-10">
    <input type="text" class="form-control" id="inputEmail" name="inputEmail" placeholder="Your Email">
    </div>
</div>
<div class="form-group">
<label for="inputSubject" class="col-lg-2 control-label">Subject</label>
    <div class="col-lg-10">
    <input type="text" class="form-control" id="inputSubject" name="inputSubject" placeholder="Subject Message">
    </div>
</div>
<div class="form-group">
<label for="inputPassword1" class="col-lg-2 control-label">Message</label>
    <div class="col-lg-10">
    <textarea class="form-control" rows="4" id="inputMessage" name="inputMessage" placeholder="Your message..."></textarea>
    </div>
</div>

<div class="form-group">
<center>
    <div class="col-lg-offset-2 col-lg-10">
    <button type="submit" class="btn btn-primary">Send Message</button>
    </div>
</center>
</div> 
</form>

名称
电子邮件
主题
消息
发送消息
PHP

您是使用PHP的mail()函数,还是连接到服务器并通过SMTP发送邮件?不管是什么情况,PHPMailer官方网站都有各种各样的例子。请注意,如果您想测试通过SMTP发送邮件,您可以配置一个gmail帐户,然后随意使用它


你怎么知道它不起作用?您所显示的只是文件位置。@对不起,现在添加的代码在您不使用PHPMailer时不要将其标记为PHPMailer(尽管如果您这样做,可能不会有此问题)。我使用的是php mail()函数。我更新了问题以显示我的代码。请将此作为修复代码的指南。:)mail()函数需要4个参数,我不知道。我添加了$name,所以我的邮件功能现在是mail($myemail,$name,$subject,$message);-这是正确的吗?我的收件箱仍然没有收到任何消息
<?php
/* Set e-mail recipient */
$myemail = "my_address@gmail.com";

/* Check all form inputs using check_input function */
$name = check_input($_POST['inputName'], "Your Name");
$email = check_input($_POST['inputEmail'], "Your E-mail Address");
$subject = check_input($_POST['inputSubject'], "Message Subject");
$message = check_input($_POST['inputMessage'], "Your Message");

/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("Invalid e-mail address");
}
/* Let's prepare the message for the e-mail */

$subject = "Someone has sent you a message";

$message = "

Someone has sent you a message using your contac form:

Name: $name
Email: $email
Subject: $subject

Message:
$message

";

/* Send the message using mail() function */
mail($myemail, $subject, $message);

/* Redirect visitor to the thank you page */
header('Location: http://location_of_my_thank_you_page/Static/contact_thankyou.html');
exit();

/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}

function show_error($myError)
{
?>
<html>
<body>

<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>

</body>
</html>
<?php
exit();
}
?>