使用代码点火器发送电子邮件



遇到 PHP 错误 严重性:8192

消息:idn_to_ascii((:INTL_IDNA_VARIANT_2003已弃用

文件名:库/电子邮件.php

行号:1868

回溯:

文件:/home/abc/public_html/isol/application/controllers/Home.php 行: 261 功能:发送

文件:/home/abc/public_html/isol/index.php 行: 315 功能:require_once

每当我发送电子邮件时,我都会收到此错误。 我的代码如下

$config = Array('mailtype' => 'html');
$this->load->library('email',$config);
$this->email->set_newline("rn"); 
$this->email->from(from_email,site_title); 
$this->email->to('ammarkhan94x@gmail.com');
$this->email->subject(site_title.' - Account Registration'); 
$this->email->message('<p><b>Dear '.$fname.' '.$lname.',</b></p>'.
'<p>Thank You for registration on '.site_title.', Your account is created successfully please login & update your account details.</p>');		
$result = $this->email->send();

此问题已在更新中得到解决。

您可以在此处阅读有关它的更多信息:https://github.com/bcit-ci/CodeIgniter/issues/5300

因此,您应该将 CI 的/system升级到最新版本,您的问题应该会消失。

您也可以在index.php页面顶部的 switch 语句中静音折旧警告,但这更像是创可贴而不是修复。

In Application/config/email.php

<?php
$config['email_conf'] = Array(
'protocol' => 'smtp',
'smtp_host' => '-your smtp port-',
'smtp_port' => -your smtp port-,
'smtp_user' => '-your email--',
'smtp_pass' => '-your smtp pass',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);

在控制器中

private function sendMail($mailBody) {
//en-tête de mail
$filename = 'assets/images/logo.png';
//loader les fichiers de configuration
$this->config->load('email');
$conf = $this->config->item('email_conf');
$this->load->library('email', $conf);
$this->email->set_newline("rn");
$this->load->library('email');
$this->email->from('mail address', 'your name');
$this->email->subject('Support Application');
$this->email->attach($filename);
$this->email->to('email dest');
$cid = $this->email->attachment_cid($filename);
$message = '<div><img src="cid:' . $cid . '" alt="photo1"/></div>';
$message .=  $mailBody  ;
//array à passer au template email
$data = array(
'userName' =>  $this->session->userdata('username'),
'email' => $this->session->userdata ('email'),
'message' => $message
);
$body = $this->load->view('email/template.php', $data, TRUE);
$this->email->message($body);
$this->email->set_crlf( "rn" );
$result = $this->email->send();
}
}

我在新的视图文件夹视图/电子邮件/模板中创建了一个模板作为视图.php

<html lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Template contact / XXX</title>
</head>
<body>
<p>
<FONT face="Verdana" size = "4" ><?php echo $message; ?></FONT>
<FONT face="Verdana" size = "4" >Message envoyé par : <?php echo   $userName; ?></FONT>
<FONT face="Verdana" size = "4" >test mail : <?php echo $email; ?></FONT>
</p> 
</body>
</html>

让我知道它是否有帮助。

相关内容

  • 没有找到相关文章

最新更新