Guest User

Untitled

a guest
Aug 19th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. emailing using phpmailer using post data for email address
  2. <!DOCTYPE html>
  3. <html>
  4. <form method='post'>
  5. <input type='email' value='@domain.com' name='emailaddress'>
  6. <input type='submit' value='submit' name='submit'>
  7. </form>
  8. </html>
  9. <?php
  10. if (isset($_REQUEST['Submit'])) {
  11. require("class.phpmailer.php");
  12. $mail = new PHPMailer();
  13. $mail-> IsSMTP();
  14. $mail->Host = "mail.domain.com";
  15.  
  16. $mail->Username = 'username';
  17. $mail->Password = 'password';
  18. $mail->From = "foo@bar.com";
  19. $mail->FromName = "foo bar";
  20. $mail->AddAddress = (HERE IS WHERE I WANT TO ENTER emailaddress FROM THE FORM);
  21. $mail->Subject = "test1";
  22. $mail->Body = "Test 1 of PHPMailer.";
  23. $mail->IsHTML(true);
  24. $mail->Port = 25;
  25. $mail->AddAttachment('sample.pdf','sample.pdf');
  26. //$mail->SMTPSecure = 'ssl';
  27. if(!$mail->Send())
  28. {
  29. echo "Message did not sent <p>";
  30. echo "Mailer Error: " . $mail->ErrorInfo;
  31. exit;
  32. }
  33.  
  34. echo "Message has been sent";
  35.  
  36.  
  37. }
  38. ?>
  39.  
  40. <input type='email' value='@domain.com' name='emailaddress'>
  41.  
  42. $mail ->AddAddress = $_POST['emailaddress'];
Add Comment
Please, Sign In to add comment