Codeigniter电子邮件功能不适用于amazone ses

时间:2018-01-03 11:15:36

标签: php amazon-web-services email smtp codeigniter-3

我正在使用Amazone ses帐户发送电子邮件。

所有凭据在 core php 中使用 class.phpmailer.php

正常运行

但未在同一台服务器上使用 codeigniter电子邮件类

并没有向我显示任何错误 echo $ this-> email-> print_debugger();

请看一下代码

核心php代码

//include phpmailer
require_once('class.phpmailer.php');

//SMTP Settings
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth   = true; 
$mail->SMTPSecure = "tls"; 
$mail->Host       = "email-smtp.us-west-2.amazonaws.com";
$mail->Username   = "AKIAIF4U4***5J36ROIA";
$mail->Password   = "AhI9Nn********GSo4u8r0xNK/OI";
//

$mail->SetFrom('donotreply@*****.com', 'medi***'); //from (verified email address)
$mail->Subject = "Email Subject"; //subject

//message
$body = "This is a test message vipul.";
$body = eregi_replace("[\]",'',$body);
$mail->MsgHTML($body);

//recipient
$mail->AddAddress("vipul.kumar@******.com", "Test Recipient"); 

//Success
if ($mail->Send()) { 
    echo "Message sent!"; die; 
}

//Error
if(!$mail->Send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} 

codeigniter代码

public function test_aws_email($data=array()){

$config = array(
    'protocol' => 'smtp',
    'smtp_host' => 'tls://email-smtp.us-west-2.amazonaws.com',
    'smtp_port' => 465,
    'smtp_user' => 'AKIAIF4U4***5J36ROIA',
    'smtp_pass' => 'AhI9Nn********GSo4u8r0xNK/OI'
);
$config['crlf'] = "\r\n";
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from("donotreply@******.com", 'Medi***');
$this->email->to('vipul.kumar@******.com');
$this->email->subject('TEST FOR AWS ');
$this->email->message('AWS AUTHENTICATION CLEAR ');
$this->email->set_mailtype("html");
$this->email->send();
echo $this->email->print_debugger();

}

0 个答案:

没有答案