I am using SMTP details of remove server. Here is the code snippet.
    $mail = new PHPMailer;
    $mail->IsSMTP();                                      // Set mailer to use SMTP
    $mail->Host = isset($_GET['host'])?$_GET['host']:"mail.u@xyz.com";    
    $mail->Port = isset($_GET['port'])?$_GET['port']:"465";                            
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = "testemail@xyz.com";              
    $mail->Password = "xxx";               
    $mail->SMTPSecure = 'ssl';
    $mail->SMTPOptions = array(
        'ssl' => array(
            'verify_peer' => true,
            'verify_peer_name' => true,
            'allow_self_signed' => false
        )
    );
    $mail->SMTPDebug=2;
 
    