Answer the question
In order to leave comments, you need to log in
Why is phpmailer not sending files?
Why isn't the file sent by email?
<?
require_once 'PHPMailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->CharSet = 'utf-8';
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$messages = $_POST['messages'];
$mail->From = '[email protected]';
$mail->FromName = 'КРЫМ-ХОЛСТ';
$mail->Subject = 'КРЫМ-ХОЛСТ | Заявка';
$mail->Body = 'Имя: '.$name.' Email:'.$email.' Телефон:'.$phone.' Сообщение:'.$messages;
$mail->AddAddress( [email protected]');
for ($ct = 0; $ct < count($_FILES['userfile']['tmp_name']); $ct++) {
$uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['userfile']['name'][$ct]));
$filename = $_FILES['userfile']['name'][$ct];
if (move_uploaded_file($_FILES['userfile']['tmp_name'][$ct], $uploadfile)) {
$mail->addAttachment($uploadfile, $filename);
} else {
echo 'Error Files';
}
}
if (!$mail->Send()){
echo 'Error';
} else {
header('Location: good');
}
<input type="file" name="userfile" multiple="">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question