PHPMailer funktioniert nicht mit Gmail SMTP [closed]

Der folgende Code funktioniert auf meinem lokalen xampp-Server, sendet jedoch keine E-Mails auf einem Remote-Host. Ich bekomme diesen Fehler:

Message konnte nicht gesendet werden.Mailer-Fehler: SMTP-Verbindung () fehlgeschlagen

require_once('header.php');
require_once('PHPMailer/PHPMailerAutoload.php');
function sendMail($address, $message){
    $mail = new PHPMailer;
    //$mail->SMTPDebug = 3;                 // Enable verbose debug output
    $mail->isSMTP();                        // Set mailer to use SMTP
    $mail->Host = 'smtp.gmail.com';         // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                 // Enable SMTP authentication
    $mail->Username = 'mymail@gmail.com';   // SMTP username
    $mail->Password = 'mypass';             // SMTP password
    $mail->SMTPSecure = 'tls';              // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 587;                      // TCP port to connect to
    $mail->SMTPOptions = array(
      'ssl' => array(
          'verify_peer' => false,
          'verify_peer_name' => false,
          'allow_self_signed' => true
      )
    ); 
    $mail->setFrom('mymail@gmail.com', 'ID Test');   // Add a recipient
    $mail->addAddress($address);               // Name is optional
    //$mail->addReplyTo('info@example.com', 'Information');
    //$mail->addCC('cc@example.com');
    //$mail->addBCC('bcc@example.com');

    $mail->isHTML(false);                      // Set email format to HTML

    $mail->Subject = 'Twitter search';
    $mail->Body    = $message;
    //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
}