lundi 9 mars 2015

PHP x Mailgun email with attachment


Vote count:

0




Im trying to do a newsletter using Mailgun.


Its sending emails well, but i need to be able to send attachments too, im trying a lot of ways to do it but nothing seems to work.


Can you guys help me out?


here´s my code: (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>


Thanks.



asked 42 secs ago







PHP x Mailgun email with attachment

Aucun commentaire:

Enregistrer un commentaire