Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.16 KB | None | 0 0
  1. <?php
  2. require 'PHPMailerAutoload.php';
  3. $mail = new PHPMailer;
  4.  
  5. //sumbission data
  6. $ipaddress = $_SERVER['REMOTE_ADDR'];
  7. $date = date('d/m/Y');
  8. $time = date('H:i:s');
  9.  
  10. //form data
  11. $name = $_POST['name'];
  12. $email = $_POST['email'];
  13. $subject = $_POST['subject'];
  14. $message = $_POST['message'];
  15.  
  16.  
  17. //$mail->SMTPDebug = 3;                               // Enable verbose debug output
  18.  
  19. // $mail->isSMTP();                                      // Set mailer to use SMTP
  20. // $mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
  21. // $mail->SMTPAuth = true;                               // Enable SMTP authentication
  22. // $mail->Username = 'user@example.com';                 // SMTP username
  23. // $mail->Password = 'secret';                           // SMTP password
  24. // $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  25. // $mail->Port = 587;                                    // TCP port to connect to
  26.  
  27. $mail->setFrom($email);
  28. $mail->addAddress('eugeneentrepreneur@gmail.com', 'Duhan Law');     // Add a recipient
  29. // $mail->addAddress('ellen@example.com');               // Name is optional
  30. $mail->addReplyTo($email);
  31. $mail->addCC('cc@example.com');
  32. $mail->addBCC('bcc@example.com');
  33.  
  34. $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
  35. $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  36. $mail->isHTML(true);                                  // Set email format to HTML
  37.  
  38. $mail->Subject = 'Here is the subject';
  39. $mail->Body    = "<p>You have recieved a new message from the enquiries form on your website.</p>
  40.                           <p><strong>Name: </strong> {$name} </p>
  41.                           <p><strong>Email Address: </strong> {$email} </p>
  42.                           <p><strong>Subject: </strong> {$subject} </p>
  43.                           <p><strong>Message: </strong> {$message} </p>
  44.                           <p>This message was sent from the IP Address: {$ipaddress} on {$date} at {$time}</p>";
  45. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  46.  
  47. if(!$mail->send()) {
  48.     echo 'Message could not be sent.';
  49.     echo 'Mailer Error: ' . $mail->ErrorInfo;
  50. } else {
  51.     echo 'Message has been sent';
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement