使用邮件发送带有php的电子邮件

时间:2017-07-26 14:40:52

标签: php email

使用邮件发送电子邮件

我试图通过php发送电子邮件,而且我正在使用电子邮件。我使用了locaweb的电子邮件,并且我在locaweb上创建了所有内容。

我的index.php

<?php
$msg=0;
@$msg= $_REQUEST['msg'];
?>



<!DOCTYPE html>
<html lang="pt">
<head>

    <!-- meta tags requiridas -->
    <meta charset="utf-8">

    <!-- Titulo --> 
    <title>Envio de Email</title>

    <!-- favicon -->
    <link rel="shortcut icon" href="img/favicon.ico"/>

    <!-- google fonts -->
    <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i" rel="stylesheet">

    <!-- font-awesome -->
    <link rel="stylesheet" href="css/font-awesome/css/font-awesome.min.css">

    <!-- bootstrap css -->
    <link rel="stylesheet" href="css/bootstrap/bootstrap.min.css">

    <!-- style CSS -->
    <link rel="stylesheet" href="css/style.css">

</head>
<body>  
    <?php if($msg==enviado): ?>
        <h1>Mensagem enviada, agradecemos o seu contato!</h1>
    <?php else: ?>

    <form action="email.php" method="post" class="contactForm">




                              <div class="form-group">
                                <label for="nome">Nome:</label>
                                <input type="text" class="form-control" id="nome" name="nome" required/>
                            <!--        <div class="validation"></div> -->
                              </div>
                              <div class="form-group">
                                <label for="email">Email</label>
                                    <input type="text" class="form-control" id="email" name="email" required />
                            <!--    <div class="validation"></div> -->
                              </div>
                              <div class="form-group">
                                <label for="assunto">Assunto</label>
                                <input type="text" class="form-control" id="assunto" name="assunto" required/>
                            <!--    <div class="validation"></div> -->
                              </div>
                              <div class="form-group">
                                <label for="mensagem">Mensagem</label>
                                <textarea class="form-control" name="mensagem" id="mensagem" rows="5" required placeholder="Escreva alguma mensagem"></textarea>
                            <!--    <div class="validation"></div> -->
                              </div>

                               <input type="submit" name="btn_enviar"  value="Enviar"/>
    </form>
    <?php endif; ?>

                            <script src="js/jquery.js"></script>

    <!-- boostrap js -->
    <script src="js/bootstrap/bootstrap.min.js"></script>

    <!-- custom js -->
    <script src="js/custom.js"></script>
</body>
</html>

发送电子邮件及其信息的功能。

email.php

<?php


$para = "";

$assunto = "Contato pelo site";
$nome = $_REQUEST['nome'];
$email = $_REQUEST['email'];
$msg = $_REQUEST['assunto'];
$mensagem = $_REQUEST['mensagem'];

    $corpo = "<strong> Mensagem de contato</strong><br><br>";
    $corpo .= "<br><strong> Nome: </strong> $nome";
    $corpo .= "<br><strong> Email: </strong> $email";
    $corpo .= "<br><strong> Titulo: </strong> $assunto";
    $corpo .= "<br><strong> Mensagem: </strong> $mensagem";


    $header = "From : $email Reply-to: $email";
    $header .= "Content-Type: text/html; charset= utf-8";


mail($para, $assunto, $corpo, $header);

header("location:index.php?msg=enviado");



?>

在我填写信息后,我看到邮件已成功发送,但电子邮件未到达。

我正在尝试使用php邮件发送电子邮件,但它无法正常工作。

有人可以帮助我吗?

0 个答案:

没有答案