When using the mail () php function, it is not necessary to specify the From header, it is automatically substituted anyway, but if sent via phpmailer, the message is not sent without $ email -> From. Do not specify the From header is very convenient, because when transferring from a local server to a remote one, you do not need to change anything. How can I send a letter without From header to phpmailer so that it can be substituted? Mail sending code:
$email = new PHPMailer(); $email->CharSet = 'UTF-8'; $email->From = 'example@mail.ru'; if (!empty($name)) { $email->FromName = $name; } else { $email->FromName = 'Client'; } $email->Subject = 'Новая заявка'; $email->Body = $msg; $email->IsHTML(true); $email->AddAddress('example@mail.ru'); if ($_FILES['file_attach']) { $email->AddAttachment($_FILES['file_attach']['tmp_name'], $_FILES['file_attach']['name']); } if (!empty($_POST[$required_field])) { // отправка сообщения if ($email->Send()) { $result = 1; echo json_encode($result); } else { $result = 0; echo json_encode($result); } } else { $result = 0; echo json_encode($result); } I would be grateful for any help.