W
W
Wyfer2020-11-15 15:42:55
PHP
Wyfer, 2020-11-15 15:42:55

How to make the correct encoding of the Submitter form?

Good day everyone! I use the form for sending messages from the site. Installed PHPMailer. But when sending a letter from the sender to the mail, krakozyabra comes, apparently the encoding in the sender is incomprehensible, how to register it ??? The site uses utf8 encoding and somehow it needs to be entered in the sender.
Next How to limit the letter in the sender itself, for example, 5 or 10 MB. And in the form I made the accept="image/jpeg,image/png,image/gif" tag so that I could choose only from this, how can I add rar here? application/x-rar-compressed doesn't work. Thank you very much.

<?php
// Файлы phpmailer
requireclass.phpmailer.php’;
requireclass.smtp.php’;
// Переменные
$name = $_POST[‘name’];
$number = $_POST[‘number’];
$email = $_POST[‘email’];
// Настройки
$mail = new PHPMailer;
$mail->isSMTP(); 
$mail->Host = ‘smtp.yandex.ru’; 
$mail->SMTPAuth = true; 
$mail->Username = ‘yourlogin’; // Ваш логин в Яндексе. Именно логин, без @yandex.ru
$mail->Password = ‘yourpass’; // Ваш пароль
$mail->SMTPSecure = ‘ssl’; 
$mail->Port = 465;
$mail->setFrom(‘example@yandex.ru’); // Ваш Email
$mail->addAddress(‘example@mail.ru’); // Email получателя
$mail->addAddress(‘example@gmail.com’); // Еще один email, если нужно.
// Прикрепление файлов
 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 {
 $msg .= ‘Failed to move file to ‘ . $uploadfile;
 }
 } 
 
// Письмо
$mail->isHTML(true); 
$mail->Subject = “Заголовок”; // Заголовок письма
$mail->Body = “Имя $name . Телефон $number . Почта $email”; // Текст письма
// Результат
if(!$mail->send()) {
 echo ‘Message could not be sent.’;
 echo ‘Mailer Error: ‘ . $mail->ErrorInfo;
} else {
 echo ‘ok’;
}
?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question