Answer the question
In order to leave comments, you need to log in
Why don't attachments come to a mail.ru email?
I am using phpmailer
php handler example
<?php
// Файлы phpmailer
require 'class.phpmailer.php';
require 'class.smtp.php';
$name = $_POST['name'];
$phone = $_POST['phone'];
// Настройки
$mail = new PHPMailer;
// Кодировка
$mail->CharSet = 'UTF-8';
//$mail->isSMTP();
$mail->Host = 'ssl://smtp.mail.ru';
$mail->SMTPAuth = true;
$mail->Username = 'XXXX'; // Ваш логин в Mail.ru. Именно логин, без @mail.ru
$mail->Password = 'XXXX'; // Ваш пароль
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom($name);
$mail->FromName = $name;
$mail->addAddress('[email protected]'); // Email recipient
//$mail->addAddress('[email protected]'); // Another email if needed.
// Attaching Files
for ($ct = 0; $ct < count($_FILES['file']['tmp_name']); $ct++) {
$uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['file']['name'][$ct]));
$filename = $_FILES['file']['name'][$ct];
if (move_uploaded_file($_FILES['file']['tmp_name'][$ct], $uploadfile)) {
$mail->addAttachment($uploadfile, $filename);
} else {
$msg .= 'Failed to move file to ' . $uploadfile;
}
}
// Письмо
$mail->isHTML(true);
// Заголовок письма
$mail->Subject = "Form name";
// Текст письма
$message = "Имя : " . $name . "<br>" . " Телефон : " . $phone ;
$mail->Body = $message;
// Результат
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo '';
}
?>
mail.ru
letter with an attachment arrives in the mail 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