Codeigniter 3不带smtp发送电子邮件 [英] Codeigniter 3 send email without smtp
问题描述
我没有收到电子邮件,尽管看起来一切正常。可能是托管问题?任何建议将不胜感激。这是我的代码
I am not receiving an email, though everything seems fine. May be hosting issue? Any suggestion will be appreciated. Here is my code
$this->load->library('email');
$this->email->from('info@domain.com', 'Name');
$this->email->to($seller_email);
$this->email->subject('This is subject');
$this->email->message('This is message!');
$this->email->send();
echo $this->email->print_debugger();
print_debugger函数返回空。
让我知道你们的评论。
print_debugger function returns empty. Let me know you guys comments.
推荐答案
完美的解决方案如下:
步骤1:
从下面的链接下载PhpMailer for CodeIgniter。
Download PhpMailer for CodeIgniter from below link.
https://github.com/ivantcholakov/codeigniter-phpmailer
步骤2:
提取。
放置第三方
,图书馆
,助手
和将 config
文件夹放入CI应用程序文件夹中。
Extract.
Put third_party
, libraries
, helpers
and config
folder into your CI application folder.
每个文件夹中只有索引文件会要求您替换。
单击替换并继续。
There will just index file(s) in each folder that will ask you to replace. Click replace and continue.
步骤3:
打开 application / config / email.php
然后根据您的电子邮件帐户进行一些更新。我使用的是gmail,因此我提供了如下的gmail设置。
And do some updates according to your email account. I am using gmail, so I am giving gmail settings as below.
$config['protocol'] = 'smtp'; // 'mail', 'sendmail', or 'smtp'
$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'smtp.gmail.com'; // if you are using gmail
$config['smtp_user'] = 'youremail@gmail.com';
$config['smtp_pass'] = 'sdkfjsk089sdfskKJ'; // App specific password
$config['smtp_port'] = 465; // for gmail
$config['smtp_timeout'] = 5;
步骤4:
现在,在您要发送电子邮件的控制器中。使用以下代码并将其全部完成。
Now, in your controller where you want to send email. Use below code and its all done.
$this->load->library('email');
$this->email->from('youremail@gmail.com')
->reply_to('youremail@gmail.com')
->to(someone@somedomain.com)
->subject("Subject")
->message("Your Message")
->set_mailtype('html')
->send();
这篇关于Codeigniter 3不带smtp发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!