如何发送到电子邮件

时间:2016-02-06 15:15:13

标签: php html forms

嘿伙计们,我正在尝试将表单发送到电子邮件,这是我的代码:

<?php 
if(isset($_POST['submit'])){
    $to = "mohamedsasa201042@yahoo.com"; // this is your Email address
    $from = $_POST['email']; // this is the sender's Email address
    $first_name = $_POST['first_name'];
    $last_name = $_POST['last_name'];
    $subject = "Form submission";
    $subject2 = "Copy of your form submission";
    $message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
    $message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];

    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers);
    mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
    echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
    // You can also use header('Location: thank_you.php'); to redirect to another page.
    }
?>
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
    <table>
    <tr>
    <td>Name:<input type="text" name="name" value="" /></td>
    </tr>
    <tr>
    <td>Email:<input type="email" name="email" value="" /></td>
    </tr>
    <tr>
    <td>Phone:<input type="text" name="email" value="" /></td>
    </tr>
    <tr>
    filename:<input type="file" name="upload" />
    <br />
    <input type="submit" name="submit" value="upload" />
    </tr>
    </table>
</form>
</body>
</html>

此表单批准上传但不发送表单到电子邮件,任何人都可以帮助将表单发送到电子邮件???

0 个答案:

没有答案