我有以下email.php文件:
<?php
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['newline'] = "rn";
?>在控制器里我有下一个:
$this->load->library('email');
$this->email->from('agro@agro.com', 'Agro');
$this->email->to($Nom_usu);
$this->email->subject('Confirmar registro');
$this->email->message('<a href="'.base_url().'Cregistro/confirm/'.$Nom_usu.'">Click Aqui</a>');
$this->email->send();然而,当我试图发送电子邮件时,我得到了下一个答复:
string(992) "Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Mon, 1 Oct 2018 00:33:26 -0400
From: "Agro" <agro@agro.com>
Return-Path: <agro@agro.com>
Reply-To: <agro@agro.com>
X-Sender: agro@agro.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5bb1a396c22bb@agro.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_5bb1a396c22cb"
=?UTF-8?Q?Confirmar=20registro?=
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_5bb1a396c22cb
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Click Aqui
--B_ALT_5bb1a396c22cb
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
=3Ca href=3D=22http://localhost/WebAgro2/Cregistro/confirm/juan.rodriguez=
=40ideasfractal.com=22=3EClick Aqui=3C/a=3E
--B_ALT_5bb1a396c22cb--
"我关注了很多类似的问题,但似乎没有什么效果。我在linux中使用localhost。
任何帮助都是非常感谢的!
发布于 2018-10-01 05:31:34
在本地主机上测试电子邮件有两种方法,一种是收邮员,您需要在您的开发机器超级简单smtp服务器上安装邮件捕捉器,另一种是邮购陷阱,我更喜欢邮箱陷阱,不需要安装任何东西,在邮箱上创建一个帐户,并且一旦您登录就可以在本地主机上测试您的电子邮件,您就可以从邮件陷阱获得您的帐户设置了。
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['newline'] = "rn";
if(ENVIRONMENT == 'development'){
$dev_config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.mailtrap.io',
'smtp_port' => 2525,
'smtp_user' => 'smtp_user_from_your_mailtrap',
'smtp_pass' => 'smtp_pass_from_your_mailtrap',
'crlf' => "\r\n",
'newline' => "\r\n"
);
$config = array_merge($config, $dev_config);
}
$this->email->initialize($config);和愉快的本地电子邮件测试。
https://stackoverflow.com/questions/52584599
复制相似问题