首页 文章

CodeIgniter为版本2.1.2全局设置smtp电子邮件

提问于
浏览
0

在我的项目中,CodeIgniter版本是2.1.2

这里是系统库,电子邮件是从sendmail发送的

但我想在不使用sendemail的情况下全局设置smtp,并且不想在每个地方发送电子邮件之前设置配置参数 .

为了解决这个问题,我在路径“application \ config \ email.php”上添加了email.php文件 .

添加以下参数值

$config['useragent'] = 'CodeIgniter';
$config['protocol'] = 'smtp';
//$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = 'youremailaddress@gmail.com';
$config['smtp_pass'] = 'yourpassword';
$config['smtp_port'] = 465; 
$config['smtp_timeout'] = 5;
$config['wordwrap'] = TRUE;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['bcc_batch_mode'] = FALSE;
$config['bcc_batch_size'] = 200;

但它给我如下错误遇到以下SMTP错误:

Failed to send AUTH LOGIN command. Error: 
from: 
The following SMTP error was encountered: 
to: 
The following SMTP error was encountered: 
data: 
The following SMTP error was encountered: 

The following SMTP error was encountered: 
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

任何人都可以帮助我解决这个问题或任何其他方式以全局方式设置smtp?

我会很感激最好的答案 .

1 回答

  • 0

    试试这个 ...

    'protocol'  => 'smtp',
    'smtp_host' => 'smtp.gmail.com',
    'smtp_port'     => 587,
    'smtp_user'     => 'youremail',
    'smtp_pass'     => 'yourpass',
    'mailtype'      => 'html',
    'smtp_crypto'   => 'tls',
    'charset'       => 'iso-8859-1',
    'clrf'      => "\r\n",
    'newline'   => "\r\n",
    

    这是我连接所需的主要参数 .

相关问题