如何在 linux localhost 中使用代码点火器发送电子邮件



我有以下电子邮件.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 中使用本地主机。

任何帮助不胜感激!

有两种方法可以在本地主机上测试电子邮件,一种是Mailcatcher,您需要在开发机器上安装Mailcatcher超级简单的SMTP服务器,其他是mailtrap我更喜欢mailtrap无需安装任何东西,在mailtrap上创建一个帐户,您就可以在本地主机上测试您的电子邮件了,登录后您可以从mailtrap获取您的帐户设置

$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' => "rn",
'newline' => "rn"
);
$config = array_merge($config, $dev_config);
}
$this->email->initialize($config);

和快乐的本地电子邮件测试。

确保在配置文件中至少设置了这四个配置首选项email.php

$config['protocol'] = 'sendmail';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;

相关内容

  • 没有找到相关文章

最新更新