简体   繁体   English

使用mailgun库,codeigniter发送电子邮件附件

[英]Sent email attachment using mailgun library, codeigniter

Can anyone please guide me how to send an attachment using mailgun and codeigniter. 谁能指导我如何使用mailgun和codeigniter发送附件。 Searching it from last 3 days and not finding any proper clue that how deal with it. 最近3天对其进行搜索,但没有找到任何适当的线索来对其进行处理。 This is my array of data: 这是我的数据数组:

$postFields = array(
        "from" => $from,
        "to" => $to,
        "subject" => $subject,
        "html" => $html,
        "text" => $text,
        "o:tag" => $tag,
        "o:dkim" => "yes",
    );

Please help me that how to append an attachment. 请帮助我,如何附加附件。 Tried appending attachment many times while following answers but got failed to receive any of the attachments. 在遵循答案时尝试了多次附加附件,但未能收到任何附件。

First of all you should insert your Mailgun smtp details into email config file located in config/email.php, then you can send emails through Mailgun. 首先,您应该将Mailgun smtp详细信息插入位于config / email.php的电子邮件配置文件中,然后才能通过Mailgun发送电子邮件。 then determine your attachment file using below code: 然后使用以下代码确定您的附件文件:

$this->email->attach('/path/to/file.format');

After set other options mail will send! 设置其他选项后,邮件将发送! For more details you can visit: https://www.codeigniter.com/user_guide/libraries/email.html 有关更多详细信息,您可以访问: https : //www.codeigniter.com/user_guide/libraries/email.html

If there isn't any email.php file in the config folder just create it simply then paste and edit below code into it: 如果config文件夹中没有任何email.php文件,只需创建它,然后将以下代码粘贴并编辑到其中即可:

<?php
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.mailgun.org';
$config['smtp_port'] = 465;
$config['smtp_user'] = '';
$config['smtp_pass'] = '';
$config['smtp_timeout'] = '4';
$config['crlf'] = '\n';
$config['newline'] = '\r\n';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';

?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM