Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PHP SMTP mail function doesn't send mail with concatenated string address
- <?php
- require_once "Mail.php";
- $host = "smtp.domain.com";
- $username = "user@domain.com";
- $password = "validpass";
- if(isset($_POST['submit'])) {
- $address = $username.$mailprovider;
- $emailTo = $address;
- $body = "Name: $name nnMessage: $message";
- $headers = array ('From' => 'user@domain.com', 'To' => $emailTo, 'Subject' => 'test');
- $smtp = Mail::factory('smtp', array('host'=>$host, 'auth'=>true, 'username'=>$username, 'password'=>$password));
- $mail = $smtp->send($emailTo, $headers, $body);
- if(PEAR::isError ($mail)){
- echo("<p>. $mail->getMessage().</p>");
- } else {
- echo("<p>Message successfully sent!</p>");
- }
- $emailSent = true;
- }
- ?>
Add Comment
Please, Sign In to add comment