Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', 1);
  4. require_once "class.phpmailer.php";
  5.  
  6. $mailAddress=$_POST["mailAddress"];
  7. $filepath='';
  8. if(isset($_FILES['file']))
  9. {
  10.     $filepath = 'files/'.date('jS F Y h i s A').'.png';
  11.     move_uploaded_file($_FILES['file']['tmp_name'], $filepath);
  12. }
  13.  
  14.  
  15. $mail = new PHPMailer();
  16. $mail->isSMTP();
  17. $mail->SMTPDebug = 2;
  18. $mail->Host = 'tls://smtp.gmail.com:587';
  19. //$mail->Port = 587;
  20. //$mail->SMTPSecure = 'tls';
  21. $mail->SMTPAuth = true;
  22. $mail->Username = "buenofotobudka@gmail.com";
  23.  
  24. $mail->SMTPOptions = array(
  25.     'ssl' => array(
  26.         'verify_peer' => false,
  27.         'verify_peer_name' => false,
  28.         'allow_self_signed' => true
  29.     )
  30. );
  31. //Password to use for SMTP authentication
  32. $mail->Password = "fotobudka123";
  33. //Set who the message is to be sent from
  34. $mail->setFrom('buenofotobudka@gmail.com', 'Bueno Fotobudka');
  35. //Set an alternative reply-to address
  36. $mail->addReplyTo('buenofotobudka@gmail.com', 'Bueno Fotobudka');
  37. //Set who the message is to be sent to
  38. $mail->addAddress($mailAddress, '');
  39. //Set the subject line
  40. $mail->Subject = 'Bueno Fotobudka';
  41. //Read an HTML message body from an external file, convert referenced images to embedded,
  42. //convert HTML into a basic plain-text alternative body
  43. $mail->Body = 'Zdjecie';
  44. //Replace the plain text body with one created manually
  45. //Attach an image file
  46. $mail->addAttachment($filepath, 'new_file.png');
  47. //send the message, check for errors
  48. if (!$mail->send()) {
  49.     echo "error";
  50. } else {
  51.     echo "ok";
  52. }
  53.  
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement