带附件的PHP x Mailgun电子邮件

时间:2015-03-09 17:41:21

标签: php html mailgun

我正在尝试使用Mailgun进行简报。

它发送电子邮件很好,但我也需要能够发送附件,我尝试了很多方法来做到这一点,但似乎没有任何工作。

你们可以帮助我吗?

这是我的代码:(PHP PART)

    <?php

require_once ('init.php');


if(isset($_POST['subject'], $_POST['body']))
{
    $subject = $_POST['subject'];
    $body = $_POST['body'];


    $mailgun->sendMessage(MAILGUN_DOMAIN, [
        'from'      => 'blablabla@gmail.com',
        'to'        => MAILGUN_LIST,
        'subject'   => $subject, 
        'html'      => "{$body}<br><br><a href=\"%unsubscribe_url%\">Unsubscribe</a>"
    ]);

    header ('Location ./');
}

    if(isset($_FILES['file'])) {
        $file = $_FILES['file'];
    }


?>

HTML PART:

    <body class="contact loading">


            <!--<header id="header">
                <h1 id="logo"><a href="index.html">Newsletters<span> | Teatro Aberto </span></a></h1>
            </header>!-->


            <article id="main">

                <header class="special container">
                    <span class="icon fa-envelope"></span>
                    <h2>Enviar</h2>
                    <p></p>
                </header>


                    <section class="wrapper style4 special container small">


                            <div class="content">
                                <form action="send.php" method="post">
                                    <div class="row half no-collapse-1">
                                    </div>
                                    <div class="row half">
                                        <div class="12u">
                                            <input type="text" name="subject" placeholder="Assunto" autocomplete="off"/>
                                        </div>
                                    </div>
                                    <div class="row half">
                                        <div class="12u">
                                            <textarea name="body" placeholder="Messagem" rows="7"></textarea>
                                        </div>
                                    </div>

                                    </br>

                                    <div class="row">
                                        <div class="12u">
                                            <ul class="buttons">
                                                <input type="submit" value="Enviar" class="button special">
                                            </ul>
                                        </div>
                                    </div>
                                </form>

                            </div>

                            </br>
                            </br>
                    </section>

            </article>


            <footer id="footer">

                <ul class="icons">
                    <li><a href="#" class="icon circle fa-facebook"><span class="label">Facebook</span></a></li>
                </ul>

                <span class="copyright">&copy;All rights reserved.  </span>

            </footer>

    </body>
</html>

感谢。

0 个答案:

没有答案