0

我在发送电子邮件时遇到问题。

我想我需要一个 js 文件。但主题制作人表示没有必要。他说他只需要html文件和php文件。

他说他只需要添加 $to_Email = "myemail@mydomain.com"; 从contact.php

但是,电子邮件表单仍然不起作用。

我想我需要一个 js 文件...是否只能使用 php?

<div id="contact-form">
  <div id="message"></div>
   <form method="post" action="php/contact.php" name="contactform" id="contactform">
    <input name="name" type="text" id="name"  onClick="this.select()" value="Name" >
    <input name="email" type="text" id="email" onClick="this.select()" value="E-mail" >            
    <input type="text"  name="phone" id="phone" onClick="this.select()" value="Phone" /> 
    <textarea name="comments"  id="comments" onClick="this.select()" >Message</textarea>

<button type="submit"  id="submit"  data-top-bottom="transform: translateY(-50px);" data-bottom-top="transform: translateY(50px);"><span>Send Message </span></button>                                                                                                      
</form>
</div>
<?php

if(!$_POST) exit;

// Email address verification, do not edit.
function isEmail($email) {

if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");

$name     = $_POST['name'];
$email    = $_POST['email'];
$phone   = $_POST['phone'];
$comments = $_POST['comments'];
$verify   = $_POST['verify'];

if(trim($name) == '') {
    echo '<div class="error_message">You must enter your name.</div>';
    exit();
} else if(trim($email) == '') {
    echo '<div class="error_message"> Please enter a valid email address.</div>';
    exit();
} else if(trim($phone) == '') {
    echo '<div class="error_message">Please enter a valid phone number.</div>';
    exit();
} else if(!is_numeric($phone)) {
    echo '<div class="error_message">Phone number can only contain digits.</div>';
    exit();
} else if(!isEmail($email)) {
    echo '<div class="error_message">You have enter an invalid e-mail address, try again.</div>';
    exit();
}

if(trim($comments) == '') {
    echo '<div class="error_message">Please enter your message.</div>';
    exit();
} 

if(get_magic_quotes_gpc()) {
    $comments = stripslashes($comments);
}


//$address = "myemail@mydomain.com";
$address = "myemail@mydomain.comm";


// Configuration option.
// i.e. The standard subject will appear as, "You've been contacted by John Doe."

// Example, $e_subject = '$name . ' has contacted you via Your Website.';

$e_subject = 'You\'ve been contacted by ' . $name . '.';

$e_body = "You have been contacted by $name with regards, their additional message is as follows." . PHP_EOL . PHP_EOL;
$e_content = "\"$comments\"" . PHP_EOL . PHP_EOL;
$e_reply = "You can contact $name via email, $email or via phone $phone";

$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );

$headers = "From: $email" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;

if(mail($address, $e_subject, $msg, $headers)) {

    // Email has sent successfully, echo a success page.

    echo "<fieldset>";
    echo "<div id='success_page'>";
    echo "<h3>Email Sent Successfully.</h3>";
    echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>";
    echo "</div>";
    echo "</fieldset>";

} else {

    echo 'ERROR!';

}
4

0 回答 0