그래서 나는 하루 이틀 동안 이것을 해왔습니다. 처음에는 코드 나이 터 SMTP 메일 클래스를 구축했는데 운이 없었습니다. 이 문제를 해결하기 위해 PHPMailer를 사용했습니다. 그리고 실망 스럽지만 여전히 행운은 없습니다.Codeigniter & PHPMailer
모든 세부 사항이 정확하다고 확신합니다. 나는 심지어 여러 개의 SMTP 서버를 시도했는데 그 중 일부는 gmail과 mandrill을 포함하고있다. 여기
내가 사용하고있는 코드입니다 (I이 다양한 수정 된 버전을 시도,하지만 난 당신에게 내가 현재 사용하고 하나의주지)<?php
class thankyou extends CI_Controller {
function index()
{
$this->load->model('index');
$header = array(
'title' => 'Please Confirm',
'navigation' => $this->index->loadNavigation(),
);
$this->load->view('header', $header);
$this->load->library('My_PHPMailer');
$mail = new PHPMailer();
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mandrillapp.com'; // Specify main and backup server
$mail->Port = 587; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'password4mandrill'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->SMTPDebug = 1;
$mail->From = '[email protected]ver.co.uk';
$mail->FromName = 'Whatever';
$mail->AddAddress('[email protected]', 'Josh Adams'); // Add a recipient // Name is optional
$mail->IsHTML(false); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <strong>in bold!</strong>';
$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;
exit;
}
}
}
?>
필요하다면, 당신이 할 수있는을 난 그냥 CodeIgniter를하기 때문에 오류 2014-06-09 11:18:40 SMTP ERROR: Failed to connect to server: Connection timed out (110) SMTP connect() failed. Message could not be sent.Mailer Error: SMTP connect() failed.
당신의 smtp 사용자 이름과 암호를 제거하십시오 – tomexsans
그들은 진짜가 아닙니다 ... – Jarrod
오케이 그래서 오류는 smtp 서버에 연결할 수 없다는 것입니다. 어쩌면 smtp 인증이 거짓이거나 설정 파일을 가지고 놀아 보려고합니다. – tomexsans