php - phpmailer not works with attachment file -
i'm trying send message file (like pdf), it's not working.
my html:
<input type=text class=form-control name="nomeee" required> <input type=text class=form-control name="emailll" required> <input type=text class=form-control name="ttel" required> <textarea class=form-control name="resumo" required></textarea> <input type="hidden" name="max_file_size" value="100000"> send file: <input name="file" type="file"> <button id="btn" class="btn btn-xl" style="font-size: 18px; padding: 11px 44px;">send</button>
my php:
require_once('class.phpmailer.php'); include 'phpmailerautoload.php'; $msg = ''; $nomeee = $_post['nomeee']; $emailll = $_post['emailll']; $ttel = $_post['ttel']; $resumo = $_post['resumo']; // attachment , upload $tmp_name = $_files['file']['tmp_name']; $name = $_files['file']['name']; move_uploaded_file($tmp_name, '/upload/'.$name); $mail = new phpmailer; $mail->issmtp(); $mail->host = 'smtp.gmail.com'; $mail->smtpauth = true; $mail->username = 'email@gmail.com'; $mail->password = 'pass'; $mail->smtpsecure = 'ssl'; $mail->port = 465; $mail->ishtml(true); $mail->from = 'email-from'; $mail->addreplyto($emailll, $nomeee); $mail->fromname = $nomeee.' - formulário de contato - site pallina gellateria'; $mail->charset = 'utf-8'; $mail->addaddress('email-address'); $mail->addattachment('/upload/'.$tmp_name, $name, 'base64', 'mime/type'); $mail->subject = 'subject'; $mail->body = '<h1>message</h1> <br><br> <strong>name: </strong>'.$nomeee.'<br> <strong>e-mail: </strong>'.$emailll.'<br> <strong>tel: </strong>'.$ttel.'<br> <strong>resumel: </strong>'.$resumo.'<br>'; if (!$mail->send()) { $msg .= "mailer error: " . $mail->errorinfo; } else { $msg .= "message sent!"; }
i tried use phpmailer example, this example , another example not works.
the email sent, attachment not
well, i'm doing of wrong? how can solve it?
Comments
Post a Comment