0

I try to change the from Root user in PHP mailer

 require 'mailer/PHPMailerAutoload.php';

      $mail = new PHPMailer(true);
      $mail->isSMTP();                                      
      $mail->Host = 'localhost';  
      $mail->SMTPAuth = true;                              
      $mail->Username = '';                
      $mail->Password = '';                           
      $mail->SMTPSecure = 'tls';                          
      $mail->Port = 25;                                  



     try{ $mail->addAddress('user@gmail.com', 'Poweronups');

      $mail->addReplyTo($_POST['email'], 'Information');
       $mail->SetFrom('info@user.com', 'user');
      $mail->isHTML(false);                                 
      $mail->Subject = 'Poweron Contact Details';
      $mail->Body    = "Name : ".$_POST['full_name']. "\r\n" .
            "Email : ".$_POST['email']. "\r\n" .
            "Website : ".$_POST['website']. "\r\n" .
            "Message : ".$_POST['message'];

      if(!$mail->send()) {
          $_SESSION['contact_alert'] = 'Message could not be sent.';
          $_SESSION['contact_alert'] = 'Mailer Error: ' . $mail->ErrorInfo;

      } else {
         $_SESSION['contact_alert'] = 'Thank you !'. "\r\n" .

             'Your message has been successfully sent . We will contact you very soon !';
           $mail->addAddress($_POST['email'], 'user');    
          $mail->addReplyTo('info@user.com', 'Information');
          $mail->isHTML(false);                                 
          $mail->Subject = 'Poweron Contact Details';
          $mail->Body    = "Hai ".$_POST['full_name'].". Your Contact Details Has Been Sent Successfully.The Contact Team Will Get Back To You ASAP.";
          $mail->send();
      }
    } catch (phpmailerException $e) {
 echo $e->getMessage();

in this case when i add $mail->SetFrom('info@user.com', 'Poweronups'); and try to send mail page goes to blank page.without this it will works perfectly.but it shows the root user.

user94
  • 409
  • 1
  • 6
  • 20
  • Possible duplicate of [How to change from-address when using gmail smtp server](https://stackoverflow.com/questions/1332510/how-to-change-from-address-when-using-gmail-smtp-server) – Synchro Jul 03 '17 at 09:26
  • Please search before posting. Gmail does not allow you to send form arbitrary from addresses, though you can create preset aliases. – Synchro Jul 03 '17 at 09:26

0 Answers0