Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'phpmailer/PHPMailerAutoload.php';
- /*проверяем, если файл загружен и ошибок нет*/
- if($_FILES['upload']['error'] == 0){
- /*выбираем путь временного хранилища файла*/
- $temp = $_FILES['upload']['tmp'];
- /*выбираем путь, куда будем сохранять файл*/
- $name_file = $_FILES['upload']['name'];
- /*перемещаем файл из временной папки к нам на сервер*/
- move_uploaded_file($temp, "uploads/".$name_file);
- $mail = new PHPMailer;
- //$mail->SMTPDebug = 3; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = ;
- $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->From = ;
- $mail->FromName = 'Mailer';
- $mail->addAddress('', 'Joe User'); // Add a recipient
- $mail->addAttachment("uploads/".$name_file); // Add attachments
- // Set email format to HTML
- $mail->Subject = 'Here is the subject';
- $mail->Body = 'This is the HTML message body <b>in bold!</b>';
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- $mail->IsHTML(true);
- if(!$mail->send()) {
- unlink('uploads/'.$name_file);
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- unlink("uploads/".$name_file);
- echo 'Message has been sent';
- }
- }
- else {
- echo 'error';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement