Guest User

Untitled

a guest
Sep 6th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. PHP SMTP mail function doesn't send mail with concatenated string address
  2. <?php
  3. require_once "Mail.php";
  4.  
  5. $host = "smtp.domain.com";
  6. $username = "user@domain.com";
  7. $password = "validpass";
  8.  
  9. if(isset($_POST['submit'])) {
  10. $address = $username.$mailprovider;
  11. $emailTo = $address;
  12. $body = "Name: $name nnMessage: $message";
  13.  
  14. $headers = array ('From' => 'user@domain.com', 'To' => $emailTo, 'Subject' => 'test');
  15.  
  16. $smtp = Mail::factory('smtp', array('host'=>$host, 'auth'=>true, 'username'=>$username, 'password'=>$password));
  17.  
  18. $mail = $smtp->send($emailTo, $headers, $body);
  19.  
  20.  
  21. if(PEAR::isError ($mail)){
  22. echo("<p>. $mail->getMessage().</p>");
  23. } else {
  24. echo("<p>Message successfully sent!</p>");
  25. }
  26.  
  27. $emailSent = true;
  28.  
  29. }
  30.  
  31. ?>
Add Comment
Please, Sign In to add comment