2017-03-24 7 views
0

私は 'phpmailer'クラスを使ってSMTPサーバを設定しようとしています。私は '1and1'メールサーバから私のメールアカウントのメールとパスワードを使っています。しようとしましたが、 'SMTP' connect()のエラーが発生しました。失敗しました。何が間違っているのか分かりません。 コードソース: 'githubの'SMTPメールサーバの設定、私のホストは1and1.comです

<?php 
require 'phpmailer/PHPMailerAutoload.php'; 

$mail = new PHPMailer; 

//$mail->SMTPDebug = 3;        // Enable verbose debug output 

$mail->isSMTP();          // Set mailer to use SMTP 
$mail->Host = 'smtp.1and1.com'; // Specify main and backup SMTP servers 
$mail->SMTPAuth = true;        // Enable SMTP authentication 
$mail->Username = '[email protected]';     // SMTP username 
$mail->Password = '*********';       // SMTP password 
$mail->SMTPSecure = 'ssl';       // Enable TLS encryption, `ssl` also accepted 
$mail->Port = 993;          // TCP port to connect to 

$mail->setFrom('[email protected]', 'Mailer'); 
$mail->addAddress('[email protected]', 'Shaur');  // Add a recipient 
//$mail->addAddress('[email protected]');    // Name is optional 
//$mail->addReplyTo('[email protected]', 'Information'); 
//$mail->addCC('[email protected]'); 
//$mail->addBCC('[email protected]'); 

//$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'; 
} 
?> 

答えて

0
date_default_timezone_set('Etc/UTC'); 
require 'vendor/autoload.php'; 


$mail = new PHPMailer; 

$mail->isSMTP(); 
//Enable SMTP debugging 
// 0 = off (for production use) 
// 1 = client messages 
// 2 = client and server messages 
$mail->SMTPDebug = 2; 

$mail->Debugoutput = 'html'; 

$mail->Host = 'smtp.mailgun.org'; 

$mail->Port = 587; 

$mail->SMTPSecure = 'tls'; 

$mail->SMTPAuth = true; 

$mail->Username = "@email.com"; 

$mail->Password = "**************"; 

$mail->setFrom('emailTo','name'); 
$mail->addAddress('emailFrom', 'name'); 



$mail->addAddress(''); 

$mail->Subject = 'Test'; 

$mail->msgHTML("<h1>Succes!</h1>"); 

$mail->AltBody = 'Succes'; 

if (!$mail->send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message sent!"; 
} 

私はあまりにも、あなたのコードに同じエラーを取得しています

+0

を作品soomethingを持っています。私は問題が他のどこかにあると思う。 – user3661745

関連する問題