Last active
June 21, 2023 04:26
-
-
Save evdeveloper/abc8ba4e55888c2db6f2c319953dfb67 to your computer and use it in GitHub Desktop.
Form post file (phpmailer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
form(method="POST" id="form" class="form" enctype="multipart/form-data" action="mail.php") | |
label(for="names" ) Наименование организации: | |
input(type="text" name="user_name" id="names" placeholder="Введите наим. организации") | |
label(for="address" ) Aдрес организации: | |
input(type="text" name="user_address" id="address" placeholder="Введите адрес") | |
label(for="email" ) Email*: | |
input(type="email" name="user_email" id="email" placeholder="Введите email" required) | |
label(for="phone" ) Телефон*: | |
input(type="phone" name="user_phone" id="phone" placeholder="Введите телефон" required) | |
label(for="file" ) Прикрепить файл: | |
input(type="file" multiple="multiple" name="upload" class="file" id="file" ) | |
label(for="massage" ) Ввести сообщение: | |
textarea(class="massage" name="user_massage" placeholder="Cообщение" id="massage" ) | |
input(type="submit" name="submit" value="Отправить" class="submit" ) | |
// php | |
<?php | |
require_once('phpmailer/PHPMailerAutoload.php'); | |
$mail = new PHPMailer; | |
$mail->CharSet = 'utf-8'; | |
$phone = $_POST['user_phone']; | |
$email = $_POST['user_email']; | |
$name = $_POST['user_name']; | |
$addr = $_POST['user_address']; | |
$msg = $_POST['user_massage']; | |
// $mail->SMTPDebug = 3; // Enable verbose debug output | |
$mail->isSMTP(); // Set mailer to use SMTP | |
$mail->Host = 'smtp.mail.ru'; // Specify main and backup SMTP servers | |
$mail->SMTPAuth = true; // Enable SMTP authentication | |
$mail->Username = '**********'; // Ваш логин от почты с которой будут отправляться письма | |
$mail->Password = '(**********)'; // Ваш пароль от почты с которой будут отправляться письма | |
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted | |
$mail->Port = 465; // TCP port to connect to / этот порт может отличаться у других провайдеров | |
$mail->AltBody = ''; | |
$mail->setFrom('*********'); // от кого будет уходить письмо? | |
$mail->addAddress('************'); // Кому будет уходить письмо | |
//$mail->addAddress('ellen@example.com'); // Name is optional | |
//$mail->addReplyTo('info@example.com', 'Information'); | |
//$mail->addCC('cc@example.com'); | |
//$mail->addBCC('bcc@example.com'); | |
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments | |
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); | |
$mail->addAttachment($_FILES['upload']['tmp_name'], $_FILES['upload']['name']); | |
$mail->isHTML(true); // Set email format to HTML | |
$mail->Subject = 'Новая заявка'; | |
$mail->Body = 'Hаименование организации: ' .$name . '<br>Номер телефона: ' .$phone. '<br>Почта: ' .$email. '<br>Адрес организации: ' .$addr. '<br>Сообщение: ' .$msg; | |
$mail->AltBody = ''; | |
if(!$mail->send()) { | |
echo 'Error'; | |
} else { | |
echo 'dsdsdsd'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Form phpmailer