使用PHP和HTML发送电子邮件,无需任何数据库

使用PHP和HTML发送电子邮件,无需任何数据库,php,html,forms,email,Php,Html,Forms,Email,我想在不使用任何数据库的情况下发送电子邮件,这就是我尝试使用PHP和HTML发送电子邮件的原因,但问题是,在按下提交按钮后,它不会发送任何电子邮件。这是我的密码: <form role="form" name="contactform" id="contactform" method="POST" action="send.php" enctype="multipart/form-data"> <div class="row"> <div cl

我想在不使用任何数据库的情况下发送电子邮件,这就是我尝试使用PHP和HTML发送电子邮件的原因,但问题是,在按下提交按钮后,它不会发送任何电子邮件。这是我的密码:

<form role="form" name="contactform" id="contactform" method="POST" action="send.php" enctype="multipart/form-data">
    <div class="row">
       <div class="col-md-6">
            <div class="input-text form-group">
                     <input type="text" name="contact_name" class="input-name form-control" placeholder="Full Name" />
                                    </div>
                                    <div class="input-text form-group">
                                    <input type="email" name="email" class="input-name form-control" placeholder="Enter Email-ID" />
                                    </div>
                                    <div class="input-text form-group">
                                        <input type="text" name="contact_phone" class="input-name form-control" placeholder="Phone Number" />
                                    </div>
                                </div>
                                <div class="col-md-6">

                                    <div class="input-text form-group">
                                        <input type="text" name="contact_sub" class="input-name form-control" placeholder="Subject" />
                                    </div>
                                    <div class="textarea-message form-group">
                                        <textarea name="contact_message" class="textarea-message hight-82 form-control" placeholder="Message" rows="2"></textarea>
                                    </div>
                                </div>
                                <div class="col-md-12">

                                   <input type="submit" class="btn btn-default top-margin-10 hblack" name="Submit" value="Submit" />
                                </div>
                            </div>
                        </form>

PHP代码是:

<?php

$strTo = $_POST["contact_name"];
$strSubject = $_POST["email"];
$strMessage = nl2br($_POST["contact_phone"]);
$strSub = nl2br($_POST["contact_sub"]);
$strmsg = nl2br($_POST["contact_message"]);

$body="Job-title:$title \r\n
Name:$strTo \r\n
Email:$strSubject \r\n
Phone:$strMessage \r\n
Subject:$strSub \r\n
Message:$strmsg";
$from=$strSubject;

$to='abc@abc.com'; // removed for spam protection

mail($to,$from,$body);

echo "<script> alert('Your Form has been Submitted successfully'); window.location.href='index.php'; </script>";

?>

如果使用邮件功能,则必须对php设置进行一些服务器端更改。最常见的变化是在一个名为“php.ini”的文件中。我鼓励您在特定服务器上查找邮件功能所需的更改,并在搜索时包括有关服务器和php版本的详细信息

使用phpmailer,如果您使用mail(),则必须设置邮件服务器。。