2017-05-18 13 views
0

なぜphpMailerを使用してメールを送信中にエラーが発生しましたか?なぜphpMailerを使用してメールを送信中にエラーが発生しましたか?

<?php 
    require 'PHPMailerAutoload.php'; 

    $mail = new PHPMailer; 

    $mail->isSMTP();          // Set mailer to use SMTP 
    $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers 
    $mail->SMTPAuth = true;        // Enable SMTP authentication 
    $mail->Username = '[email protected]';     // SMTP username 
    $mail->Password = 'secret';       // SMTP password 
    $mail->SMTPSecure = 'tls';       // Enable encryption, 'ssl' also accepted 

    $mail->From = '[email protected]'; 
    $mail->FromName = 'Mailer'; 
    $mail->addAddress('[email protected]', 'Joe User');  // Add a recipient 
    $mail->addAddress('[email protected]');    // Name is optional 
    $mail->addReplyTo('[email protected]', 'Information'); 
    $mail->addCC('[email protected]'); 
    $mail->addBCC('[email protected]'); 

    $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 = 'Here is the subject'; 
    $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.'; 
     echo 'Mailer Error: ' . $mail->ErrorInfo; 
    } else { 
     echo 'Message has been sent'; 
    } 

Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

+2

可能な複製を失敗取り組んでいます。メッセージは送信されませんでした。メールエラー:SMTP Connect()が失敗しました](http://stackoverflow.com/questions/18496650/smtp-connect-failed-message-was-not-sent-mailer-error-smtp-connect-failed ) –

+0

デバッグ出力を有効にしていないのがわかります。エラーメッセージのリンクをたどったことがありますか? –

+0

ありがとうございました "独裁者" –

答えて

-1
<?php 

    $mailto = $_POST['mail_to']; 
    $mailsub = $_POST['mail_subject']; 
    $mailmsg = $_POST['mail_message']; 
    require 'includes/PHPMailer-master/PHPMailerAutoload.php'; 
    $mail = new PHPMailer(); 
    $mail ->IsSmtp(); 
    $mail ->SMTPDebug = 1; 
    $mail ->SMTPAuth = true; 
    $mail ->SMTPSecure = 'ssl'; 
    $mail ->Host = "smtp.gmail.com";//If Your sending accound server is gmail use this else change 
    $mail ->Port = 465; // or 587 
    $mail ->IsHTML(true); 
    $mail ->Username = "[email protected]"; //use your sending mail accound address 
    $mail ->Password = "abc123"; //use the account password of the above used mail. 
    $mail ->SetFrom("[email protected]");//use your sending mail accound address (Same) 
    $mail ->Subject = $mailsub; 
    $mail ->Body = $mailmsg; 
    $mail ->AddAddress($mailto); 

    if(!$mail->Send()){ 
     echo "Mail not Send"; 
    } 
    else{ 
     echo " Mail Send"; 
    } 
?> 

Tihsコードは、[SMTP接続()の

関連する問題