Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to send SMTP email with gmail account

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 97
    Comment on it

    Hello Friends,

    If you are looking to implement SMTP email via gmail account. Please follow the below code:

    $mailObj = new PHPmailObjer;
    
    
    $mailObj->SMTPDebug = 3;     //SMTP debugging on.                     
    $mailObj->isSMTP();     
    
    $mailObj->Host = "smtp.gmailObj.com"; //Setup your SMTP gmail account 
    $mailObj->SMTPAuth = true;   //Ture mean SMTP host requires authentication to send                      
    
    $mailObj->Username = "name@gmailObj.com";  //define your username credential                 
    $mailObj->Password = "super_secret_password";  //define your password credential                           
    
    $mailObj->SMTPSecure = "tls";  //Define SMTP TLS encryption to tls                       
    $mailObj->Port = 587;  //Define TCP port to connect to          
    
    $mailObj->From = "abc@xyz.com"; 
    $mailObj->FromName = "From Name";
    
    $mailObj->addAddress("receiveremail@example.com", "Receiver Name");
    $mailObj->isHTML(true);
    
    $mailObj->Subject = "Subject Text";
    $mailObj->Body = "mailObj body in HTML";
    $mailObj->AltBody = "This is the plain text version of the emailObj content";
    
    if(!$mailObj->send()) 
    {
        echo "mailObjer Error: " . $mailObj->ErrorInfo;
    }
    else 
    {
        echo "Email has been sent successfully";
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: