Getting trouble with SMTP connect with PHPMailer
<p>I am trying to send SMTP secured mail with attachment using PHPMailer. </p>

<p>I made this function with PHPMailer library </p>

<pre><code>public function sendCsv($subject,$body,$path,$mail_to,$from_name,$from_mail,$replyto){

    require getcwd() .'/lib/PHPMailerAutoload.php';             

    $mail = new PHPMailer;

    //$mail-&gt;SMTPDebug = 3;      // Enable verbose debug output

    $mail-&gt;isSMTP();              // Set mailer to use SMTP

    $mail-&gt;Host = 'smtp.gmail.com'; 
    $mail-&gt;SMTPAuth = true;                             
    $mail-&gt;Username = 'tester@mydomain.com';                
    $mail-&gt;Password = '**************';                          
    $mail-&gt;SMTPSecure = 'ssl';                            
    $mail-&gt;Port = 465;                            

    $mail-&gt;setFrom($from_mail, $from_name);
    $mail-&gt;addAddress($mail_to);  
    $mail-&gt;addReplyTo($replyto, 'no reply');

    $mail-&gt;addAttachment($path);        
    $mail-&gt;isHTML(true);                                  

    $mail-&gt;Subject = $subject;

    $mail-&gt;Body    = $body;
    //$mail-&gt;AltBody = 'This is the body in plain text for non-HTML mail clients';

    if(!$mail-&gt;Send()) {
        $error = 'Mail error: '.$mail-&gt;ErrorInfo; 
        echo  $error;
        } else {
            $sucess = 'Mail sent!';
            echo  $sucess;
            }
    }
</code></pre>

<p>Now if I comment the line $mail->isSMTP(); it's working fine . but I think it's not SMTP secured. Else I am getting this message: "Mail error: SMTP connect() failed.  "</p>

<p>I searched for this problem but didn't get the proper answer to what I am looking for. Please help me.</p>

<p>I am working in a dev server with HTACCESS protection</p>