2017-09-15 8 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/Tutorial – IcedAnt

+0

https://support.google.com/mail/answer/7104828?hl=ja&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

おっと、ちょっと... –

関連する問題