Codeigniter 发送带有附件的电子邮件

编程入门 行业动态 更新时间:2024-10-26 07:37:09
本文介绍了Codeigniter 发送带有附件的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用附件文件在 codeigniter 上发送电子邮件.

I am trying to send email on codeigniter with attach file.

我总是成功收到电子邮件.但是,我从来没有收到附件.以下是代码,非常感谢所有评论.

I always receive email successfully. However , I never receive with attach file. Below is code and highly appreciate for all comments.

$ci = get_instance(); $ci->load->library('email'); $config['protocol'] = "smtp"; $config['smtp_host'] = "ssl://smtp.gmail"; $config['smtp_port'] = "465"; $config['smtp_user'] = "test@gmail"; $config['smtp_pass'] = "test"; $config['charset'] = "utf-8"; $config['mailtype'] = "html"; $config['newline'] = " "; $ci->email->initialize($config); $ci->email->from('test@test', 'Test Email'); $list = array('test2@gmail'); $ci->email->to($list); $this->email->reply_to('my-email@gmail', 'Explendid Videos'); $ci->email->subject('This is an email test'); $ci->email->message('It is working. Great!'); $ci->email->attach( '/test/myfile.pdf'); $ci->email->send();

推荐答案

$this->email->attach()

使您能够发送附件.将文件路径/名称放在第一个参数中.注意:使用文件路径,而不是 URL.对于多个附件,多次使用该功能.例如:

Enables you to send an attachment. Put the file path/name in the first parameter. Note: Use a file path, not a URL. For multiple attachments use the function multiple times. For example:

public function setemail() { $email="xyz@gmail"; $subject="some text"; $message="some text"; $this->sendEmail($email,$subject,$message); } public function sendEmail($email,$subject,$message) { $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail', 'smtp_port' => 465, 'smtp_user' => 'abc@gmail', 'smtp_pass' => 'passwrd', 'mailtype' => 'html', 'charset' => 'iso-8859-1', 'wordwrap' => TRUE ); $this->load->library('email', $config); $this->email->set_newline(" "); $this->email->from('abc@gmail'); $this->email->to($email); $this->email->subject($subject); $this->email->message($message); $this->email->attach('C:UsersxyzDesktopimagesabc.png'); if($this->email->send()) { echo 'Email send.'; } else { show_error($this->email->print_debugger()); } }

更多推荐

Codeigniter 发送带有附件的电子邮件

本文发布于:2023-05-27 19:33:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/300575.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词库加载错误:Could not find file 'D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!