2017-09-15 1 views
0

xampp에서 php 메일러를 사용하여 메일을 보내려고했지만이 오류가 발생합니다. 메시지를 보낼 수 없습니다. 메일러 오류 : 다음 보낸 사람 주소가 실패했습니다. [email protected] : 연결하지 않고 메일()을 호출했습니다.xampp에서 phpmailer를 사용하여 메일을 보내는 방법

제발,이 문제를 해결하는 방법에 대한 도움이 필요합니다. 내 코드는 다음과 같습니다.

<?php 
require('class.phpmailer.php'); 

    $mail = new PHPMailer; 
    $mail->IsSMTP(); 
    $mail->SMTPAuth = true; 
    $mail->Host = "tls://smtp.gmail.com"; 
    $mail->Port = 25; 
    $mail->Username = "[email protected]"; 
    $mail->Password = "xxxxx"; 
    //Sending the actual email 
    $mail->setFrom('[email protected]', 'Aaron'); 
    $mail->addAddress('[email protected]', 'Aaron');  // Add a recipient 
    $mail->isHTML(false);         // Set email format to HTML 
    $mail->Subject = 'Calculation form results from '; 
    $mail->Body = 'testing...'; 

    if(!$mail->send()) { 
    echo 'Message could not be sent. '; 
    echo 'Mailer Error: ' . $mail->ErrorInfo; 
    exit; 
    } 
?> 
+1

에서 복사;'. 또한, 그것은'$ mail = new PHPMailer();'이어야합니다. https://github.com/PHPMailer/PHPMailer/wiki/ 튜토리얼 – IcedAnt

+0

https://support.google.com/mail/answer/7104828?hl=ko&visit_id=1-636410671215867907-2344642736&rd=3 포트가 잘못되었습니다. TLS에 대해 587을 시도하십시오. – IcedAnt

+0

'$ mail-> Host = "tls : //smtp.gmail.com"; $ mail-> Port = 587;'여전히 같은 오류입니다. –

답변

1

은 문자 그대로는 'PHPMailerAutoload.php'를 요구하는`사용해야 phpmailer에서 튜토리얼에 따르면 https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps

//Create a new PHPMailer instance 
$mail = new PHPMailer; 

//Tell PHPMailer to use SMTP 
$mail->isSMTP(); 

//Set the hostname of the mail server 
$mail->Host = 'smtp.gmail.com'; 
// use 
// $mail->Host = gethostbyname('smtp.gmail.com'); 
// if your network does not support SMTP over IPv6 

//Set the SMTP port number - 587 for authenticated TLS 
$mail->Port = 587; 

//Set the encryption system to use - ssl (deprecated) or tls 
$mail->SMTPSecure = 'tls'; 

//Whether to use SMTP authentication 
$mail->SMTPAuth = true; 

//Username to use for SMTP authentication - use full email address for gmail 
$mail->Username = "[email protected]"; 

//Password to use for SMTP authentication 
$mail->Password = "yourpassword"; 

//Set who the message is to be sent from 
$mail->setFrom('[email protected]', 'First Last'); 

//Set an alternative reply-to address 
$mail->addReplyTo('[email protected]', 'First Last'); 

//Set who the message is to be sent to 
$mail->addAddress('[email protected]', 'John Doe'); 
+0

대단히 고마워요! –

+0

작동하는 경우 정답으로 사용하실 수 있습니까? – IcedAnt

+0

Oo, 방금 했어요 ... –

관련 문제