Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP邮件功能赢得';t将邮件发送到所需的电子邮件\u id_Php_Email - Fatal编程技术网

PHP邮件功能赢得';t将邮件发送到所需的电子邮件\u id

PHP邮件功能赢得';t将邮件发送到所需的电子邮件\u id,php,email,Php,Email,我有下面的代码。它返回消息“发送成功”,但我们不会在给定的gmail收到电子邮件,这是正确的代码还是我错过了什么 <?php require("mailer/PHPMailerAutoload.php"); require("mailer/class.smtp.php"); require("mailer/class.phpmailer.php"); $name=$_POST['Your_Name']; $email=$_POST['Your_Email']; $message=$

我有下面的代码。它返回消息“发送成功”,但我们不会在给定的gmail收到电子邮件,这是正确的代码还是我错过了什么

   <?php

require("mailer/PHPMailerAutoload.php");
require("mailer/class.smtp.php");
require("mailer/class.phpmailer.php");
$name=$_POST['Your_Name'];
$email=$_POST['Your_Email'];
$message=$_POST['Your_Msg'];
echo $name  ;

$mail = new PHPMailer();

// set mailer to use SMTP
//$mail->IsSMTP();

// As this email.php script lives on the same server as our email server
// we are setting the HOST to localhost
$mail->Host = "smtp.gmail.com"; // specify main and backup server
$mail->Port = "465";

$mail->SMTPAuth = true; // turn on SMTP authentication

$mail->Username = "mandarpatil0003@gmail.com"; // SMTP username
$mail->Password = "Con@Soumitra1"; // SMTP password
// $email is the user's email address the specified
// on our contact us page. We set this variable at
// the top of this page with:
// $email = $_REQUEST['email'] ;
$mail->From = $email;

// below we want to set the email address we will be sending our email to.
$mail->AddAddress("mandarpatil0003@gmail.com", "Mandar");

// set word wrap to 50 characters
$mail->WordWrap = 50;
// set email format to HTML
$mail->IsHTML(true);

$mail->Subject = "You have received feedback from your website!";

// $message is the user's message they typed in
// on our contact us page. We set this variable at
// the top of this page with:
// $message = $_REQUEST['message'] ;
$mail->Body = $message;
$mail->AltBody ="Name    : {$name}\n\nEmail   : {$email}\n\nMessage : {$message}";

if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
else
{
echo "Thank you for contacting us. We will be in touch with you very soon.";
}
?>

通过Asif18使用我们自己的服务器或gmail服务器,在PHP Mailer中使用SMTP和PHP发送邮件
.作为包装{
字体系列:Arial;
颜色:#333;
字体大小:14px;
}
.我的桌子{
填充:20px;
边框:2px虚线#17A3F7;
宽度:100%;
}
使用我们自己的服务器或gmail服务器在PHP Mailer中使用SMTP和PHP发送邮件

通过Asif18使用我们自己的服务器或gmail服务器,在PHP Mailer中使用SMTP和PHP发送邮件
.作为包装{
字体系列:Arial;
颜色:#333;
字体大小:14px;
}
.我的桌子{
填充:20px;
边框:2px虚线#17A3F7;
宽度:100%;
}
使用我们自己的服务器或gmail服务器在PHP Mailer中使用SMTP和PHP发送邮件

某些邮件主机具有某种类型的安全过滤器。因此,最好尝试使用gmail、ymail等,不要使用私人电子邮件主机进行检查。
$mail->Port=“465”//也可以使用8025、587和25。将端口465用于SSL。
端口丢失可能是某些邮件主机的重复端口,并具有某种类型的安全筛选器。因此,最好尝试使用gmail、ymail等,不要使用私人电子邮件主机进行检查。
$mail->Port=“465”//也可以使用8025、587和25。将端口465用于SSL。
端口丢失了可能的副本
<?php
include 'library.php'; // include the library file
include "classes/class.phpmailer.php"; // include the class name
include "classes/class.smtp.php";
if(isset($_POST["send"])){
    $email = $_POST["email"];
    $mail   = new PHPMailer; // call the class 
    $mail->IsSMTP(); 
    $mail->SMTPAuth = true;     // turn on SMTP authentication
    $mail->SMTPSecure = "ssl";

    $mail->Host = "smtp.gmail.com"; //Hostname of the mail server
    $mail->Port = 465; //Port of the SMTP like to be 25, 80, 465 or 587
    $mail->SMTPDebug = 1;
    //$mail->SMTPAuth = false; //Whether to use SMTP authentication
    $mail->Username = "****@gmail.com"; //Username for SMTP authentication any valid email created in your domain
    $mail->Password = "****"; //Password for SMTP authentication
    $mail->AddReplyTo("****@gmail.com", "Reply name"); //reply-to address
    $mail->SetFrom("****@gmail.com", "Your Name"); //From address of the mail
    // put your while loop here like below,
    $mail->Subject = "Your SMTP Mail"; //Subject od your mail
    $mail->AddAddress($email, "Asif18"); //To address who will receive this email
    $mail->MsgHTML("<b>Hi, your first SMTP mail has been received."); //Put your body of the message you can place html code here
     //Attach a file here if any or comment this line, 

    $send = $mail->Send(); //Send the mails
    if($send){
        echo '<center><h3 style="color:#009933;">Mail sent successfully</h3></center>';
    }
    else{
        echo '<center><h3 style="color:#FF3300;">Mail error: </h3></center>'.$mail->ErrorInfo;
    }
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Send mails using SMTP and PHP in PHP Mailer using our own server or gmail server by Asif18</title>
<meta name="keywords" content="send mails using smpt in php, php mailer for send emails in smtp, use gmail for smtp in php, gmail smtp server name"/>
<meta name="description" content="Send mails using SMTP and PHP in PHP Mailer using our own server or gmail server"/>
<style>
.as_wrapper{
    font-family:Arial;
    color:#333;
    font-size:14px;
}
.mytable{
    padding:20px;
    border:2px dashed #17A3F7;
    width:100%;
}
</style>
<body>
<div class="as_wrapper">
    <h1>Send mails using SMTP and PHP in PHP Mailer using our own server or gmail server</h1>
    <form action="" method="post">
    <table class="mytable">
    <tr>
        <td><input type="email" placeholder="Email" name="email" /></td>
    </tr>
    <tr>
        <td><input type="submit" name="send" value="Send via SMTP" /></td>
    </tr>
    </table>
    </form>
</div>
</body>
</html>