使用FuelPHP和Twig以HTML格式发送Mailgun内联图像

时间:2016-08-22 08:32:05

标签: php html twig mailgun fuelphp

我有这行代码,故意向填写联系表单的人发送确认电子邮件。通常,我只发送文本,但我想在该电子邮件中发送图像。我将图像上传到postimg.org并将其放在树枝格式中,但图像没有出现。所以,让我们来看看案件

PHP

private function _send_email($post_data) {
        $data = array(
            'email_from' => 'website@XXXXX.co.id',
            'email_to' => \Config::get('config_basic.contact_us_email_to'),
            'email_subject' => 'Contact Us message from ' . $post_data['name'],
            'mail_subject' => 'Enquiry Confirmation from XXXXX',
            'email_reply_to' => array(
                'email' => $post_data['email'],
                'name' => $post_data['name']
            ), // Optional
            'email_data' => array(
                'base_url' => \Uri::base(),
                'name' => $post_data['name'],
                'email' => $post_data['email'],
                'message' => $post_data['message']
            ),
            'email_view' => 'pages::email/contact_us.twig',
            'email_respond_view' => 'pages::email/email_responder.twig',
        );

        \Util_Email::queue_send_email($data);
        $email = \Email::forge();

        // Set the from address
        $email->from($data['email_from'], 'XXXXX');
        // Set the to address
        $email->to($data['email_to'],'Web Admin of XXXXXX');
        // Set a subject
        $email->subject($data['email_subject']);
        // And set the body.
        $email->html_body(\View::forge($data['email_view'], $data['email_data']));

        $email->send();

        $mail = \Email::forge();
        $mail->from($data['email_from'], 'XXXXXX');
        $mail->to($data['email_data']['email'],$data['email_data']['name']);
        $mail->subject($data['mail_subject']);
        $mail->html_body(\View::forge($data['email_respond_view'], $data['email_data']));

        $mail->send();
    }

TWIG(email_responder.twig)

{% block frontend_content %}
    Dear {{ name }}, <br/><br/>
    Thank you for contacting us,<br/>
    our sales team would be contacting you as soon as possible<br/><br/>
    Best Regards,<br/><br/><br/>
    XXXXXX
    <div><img src="https://postimg.org/image/ynhb45hrx/" alt="city"/></div>
{% endblock %}

我只获得带有断开链接的图像的文本!你能请我给我正确的方法吗?

由于

0 个答案:

没有答案