php mailer仅向gmail发送电子邮件

时间:2018-08-15 05:34:31

标签: php email mailer

我希望大家都很好,我正在php mailer库上发送电子邮件,它工作正常,我正在接收电子邮件,但它只向使用gmail帐户申请的用户发送电子邮件,而在其他服务器上则没有身体正在接收电子邮件,我想知道我在哪里失踪

这是代码

文本/ x通用send_email.php(PHP脚本文本)     

use PHPMailer\PHPMailer\PHPMailer;

include_once "PHPMailer/PHPMailer.php";
include_once "PHPMailer/Exception.php";


$connection = mysqli_connect('localhost', 'mytaleemadmin', 'MyTal', 'mytaleem');

if (!$connection) {
    die('connection error' . mysqli_error($connection));
}

if (isset($_POST['send'])) {

    $name = $_POST['name'];
    $email = $_POST['email'];
    $address = $_POST['address'];
    $number = $_POST['number'];
    $message = $_POST['message'];
    $role = $_POST['role'];

    $message = "";

    $message .= "Name : " . $name . "<br>";

    $message .= "Email : " . $email . "<br>";

    $message .= "Address : " . $address . "<br>";

    $message .= "Cotact No : " . $number . "<br>";

    $message .= "Message : " . $message . "<br>";

    $message .= "Role : " . $role . "<br>";


    echo $message;



    if (isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != "") {

        $file = "attachment/" . basename($_FILES['attachment']['name']);
        move_uploaded_file($_FILES['attachment']['tmp_name'], $file);
    } else {
        $file = "";
    }


    $mail = new PHPMailer();
    $mail->AddAddress('omnimaroof@gmail.com');
    $mail->setFrom($email);
    $mail->Subject = "Request to join as an instructor ";
    $mail->IsHTML(true);


    $mail->Body = $message;

    $mail->addAttachment($file);

    if ($mail->send()) {

        $query = "insert into cv (name,email_address,address,number,resume,message,role) values('$name','$email','$address','$number','$file','$message','$role')";

        $run_query = mysqli_query($connection, $query);

        if ($run_query) {
            echo "success";
        } else {
            die("connection failed" . mysqli_error($connection));
        }

        $msg = "Your Email has been sent, ThankYou";
    } else {
        $msg = "Error in sending emails";
    }





    $to = $row["email_address"];
    $from = "info@omni-academy.com";
    $subject = $row["name"] . "  ThankYou For Your Cv - Omni Academy ";


    $message1 = "Name : " . $name . "<br>";

    $message1 .= "Email : " . $email . "<br>";

    $message1 .= "Address : " . $address . "<br>";

    $message1 .= "Cotact No : " . $number . "<br>";

    $message1 .= "Message : " . $message . "<br>";

    $message1 .= "Role : " . $role . "<br>";


    $headers = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";
    $headers .= "Cc: reply@omni-academy.com";

    //options to send to cc+bcc 
    //$headers .= "Cc: [email]maa@p-i-s.cXom[/email]"; 
    //$headers .= "Bcc: [email]email@maaking.cXom[/email]"; 
    // now lets send the email. 
    if (mail($to, $subject, $message1, $headers)) {
        echo "Message has been sent....!";
    } else {
        echo "message not sent";
    }
}
?>

<!DOCTYPE html>
<html>
    <head>
        <title>Php mail</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    </head>
    <body>

        <?php
        if (isset($msg)) {
            echo $msg;
        }
        ?>

        <div class="container">

            <form class="form" method="post" enctype="multipart/form-data">
                <div class="form-group">
                    Name
                    <input type="text" class="form-control" name="name">
                </div>
                <div class="form-group">
                    Email Address
                    <input type="email" class="form-control" name="email">
                </div>
                <div class="form-group">
                    address
                    <input type="text" class="form-control" name="address">
                </div>
                <div class="form-group">
                    Contact No
                    <input type="text" class="form-control" name="number">
                </div>

                <div class="form-group">
                    Your Message <textarea class="form-control" name="message"></textarea>
                </div>
                <div class="form-group">
                    <label>Role</label>
                    <select name="role">

                        <option value="web development">Web Development</option>
                        <option value="Seo"> SEO </option>
                    </select>
                </div>

                <div class="form-group">

                    <input type="file" class="form-control" name="attachment">

                </div>  

                <input type="submit" value="send email" name="send">
            </form>

        </div>

    </body>
</html>

帮我解决我失踪的地方,另一个问题是我创建了一个表格,该表格可以在我们这里申请,我希望收到在这里申请的人员的电子邮件,虽然工作正常,但同时我想回复电子邮件到各自的帐户,以感谢您的注册

0 个答案:

没有答案