PHP에서 SMTP와 PEAR을 사용하여 첨부 파일이있는 전자 메일을 보내려고하지만 "인증 실패 [SMTP (: 응답 220 : 2.0.0 TLS를 시작할 준비 코드)] "인증 실패 [SMTP : STARTTLS 실패 (코드 : 220, 응답 : 2.0.0 TLS 시작 준비 완료)]
<?php
require_once "Mail.php"; // PEAR Mail package
require_once ('Mail/mime.php'); // PEAR Mail_Mime packge
$from = "Your Mom <[email protected]>";
$to = "Me <recepient [email protected]>";
$subject = 'Call Me!';
$headers = array ('From' => $from,'To' => $to, 'Subject' => $subject);
// text and html versions of email.
$text = 'Hi son, what are you doing?nnHeres an picture of a cat for you.';
$html = 'Hi son, what are you doing?<br /><br />Here is an picture of a cat
for you.';
// attachment
$file = 'fromc.xls';
$crlf = "n";
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file, 'text/plain');
$body = $mime->get();
$headers = $mime->headers($headers);
$host = "smtp.gmail.com";
$username = "[email protected]";
$password = "xyz";
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true,
'username' => $username,'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
}
else {
echo("<p>Message successfully sent!</p>");
}
?>`
PHP 버전 : 1.10.1 PEAR 버전 : here 의 코드를 가지고
7.1.6 것은 도와주세요 STARTTLS 실패 오류를 해결하려면 ...