2016-06-03 3 views
1

Я новичок в PHP, и я пытаюсь использовать PHP Mailer в первый раз. Я установил учетную запись SMTP и ввел следующую информацию:PHPMailer не отправляет на hotmail e-mail

<?php 
    require("cscie12/final project/PHPMailer/PHPMailer_5.2.0/class.PHPMailer.php"); 

$mail = new PHPMailer(); 

$mail->IsSMTP();          // set mailer to use SMTP 
$mail->Host = "ssrs.reachmail.net"; // specify main and backup server 
$mail->Port = "25"; 
$mail->SMTPAuth = plain;  // turn on SMTP authentication 
$mail->Username = "BRYANSAY\bryan"; // SMTP username 
$mail->Password = "***********"; // SMTP password 

$mail->From = "[email protected]"; 
$mail->FromName = "Contact Form"; 
$mail->AddAddress("[email protected]", "Bryan Sayles"); 

$mail->WordWrap = 50;         // set word wrap to 50 characters 
$mail->AddAttachment("/var/tmp/file.tar.gz");   // add attachments 
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name 
$mail->IsHTML(true);         // set email format to HTML 

$mail->Subject = "Contact Form"; 
$mail->Body = "This is the HTML message body <b>in bold!</b>"; 
$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; 

if(!$mail->Send()) 
{ 
    echo "Message could not be sent. <p>"; 
    echo "Mailer Error: " . $mail->ErrorInfo; 
    exit; 
} 
} 
echo "Message has been sent"; 
?> 

Но я не получаю электронное письмо. Я получаю это на моей странице:

IsSMTP(); // set mailer to use SMTP $mail->Host = "ssrs.reachmail.net"; //   specify main and backup server $mail->Port = "25"; $mail->SMTPAuth = plain; // turn on SMTP authentication $mail->Username = "BRYANSAY\bryan"; // SMTP username $mail->Password = "********"; // SMTP password $mail->From = "[email protected]"; $mail->FromName = "Contact Form"; $mail->AddAddress("[email protected]", "Bryan Sayles"); $mail->WordWrap = 50; // set word wrap to 50 characters $mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name $mail->IsHTML(true); // set email format to HTML $mail->Subject = "Contact Form"; $mail->Body = "This is the HTML message body in bold!"; $mail->AltBody = "This is the body in plain text for non-HTML mail clients"; if(!$mail->Send()) { echo "Message could not be sent. 
"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } } echo "Message has been sent"; ?> 

Мне что-то не хватает, но не знаю, что. Вы можете помочь? Благодарю.

ответ

0

Вы можете использовать этот формат:

<?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 = "your mail id"; //Username for SMTP authentication any valid email created in your domain 
     $mail->Password = "your password"; //Password for SMTP authentication 
     $mail->AddReplyTo("[email protected]", "Reply name"); //reply-to address 
     $mail->SetFrom("your mail id", "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> 
0

Изменение:

require("cscie12/final project/PHPMailer/PHPMailer_5.2.0/class.PHPMailer.php"); 

к

require("cscie12/finalproject/PHPMailer/PHPMailer_5.2.0/class.PHPMailer.php"); 

$mail->Username = "BRYANSAY\bryan"; 

в

$mail->Username = 'BRYANSAY\bryan'; 

или избежать \b

$mail->Username = "BRYANSAY\\bryan"; 

И удалить последний кронштейн

} 

Если у вас есть проблемы, убедитесь, что вы читали:
https://mail.live.com/mail/troubleshooting.aspx

Смежные вопросы