gpt4 book ai didi

php - 使用 Gmail 在 codeigniter 中通过电子邮件类发送电子邮件

转载 作者:可可西里 更新时间:2023-11-01 00:24:37 25 4
gpt4 key购买 nike

我想在带有 gmail 的 codeigniter 中通过电子邮件类发送电子邮件,但出现以下错误:

错误:

A PHP Error was encountered
Severity: Warning
Message: mail() [function.mail]: Failed to connect to mailserver at "ssl://smtp.googlemail.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
Filename: libraries/Email.php
Line Number: 1553

这是我在控制中的全部功能:

function send_mail(){
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'xyz@gmail.com';
$config['smtp_pass'] = 'xxxxxxx';

$this->load->library('email', $config);
$this->email->set_newline("\r\n");

$this->email->from('neginph@gmail.com', 'Negin Phosphate Shomal');
$this->email->to('neginfos@yahoo.com');
$this->email->subject('This is an email test');
$this->email->message('It is working. Great!');

if($this->email->send())
{
echo 'Your email was sent, successfully.';
}

else
{
show_error($this->email->print_debugger());
}
}

我在 php.ini 中将 SMTP 更改为:

SMTP = ssl://smtp.googlemail.com
smtp_port = 25

我该怎么办?

尊重

最佳答案

这对我有用

$email_config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => '465',
'smtp_user' => 'someuser@gmail.com',
'smtp_pass' => 'password',
'mailtype' => 'html',
'starttls' => true,
'newline' => "\r\n"
);

$this->load->library('email', $email_config);

$this->email->from('someuser@gmail.com', 'invoice');
$this->email->to('test@test.com');
$this->email->subject('Invoice');
$this->email->message('Test');

$this->email->send();

关于php - 使用 Gmail 在 codeigniter 中通过电子邮件类发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9564400/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com