SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer



PHP Snippet 1:

$mail->Host = gethostbyname('smtp.gmail.com');

PHP Snippet 2:

$mail->SMTPAutoTLS = false;
$mail->SMTPSecure = false;

PHP Snippet 3:

$mail->SMTPAuth = false;

PHP Snippet 4:

    properties.put("mail.smtp.starttls.enable","true");
    properties.setProperty("mail.transport.protocol", "smtp");
    properties.setProperty("mail.host", "smtp.gmail.com");
    properties.put("mail.smtp.host","smtp.gmail.com");
    properties.put("mail.smtp.auth", "true");
    properties.put("mail.smtp.port", "465"); 
  //  properties.put("mail.debug", "true"); //this turn debug mode on to see errors!
    properties.put("mail.smtp.socketFactory.port", "465");
    properties.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
    properties.put("mail.smtp.socketFactory.fallback", "false");