Unable to send email from PHP using smtp with PHPMailer

Unable to send email from PHP using smtp with PHPMailer


<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
            require_once './resources/PHPMailer-master/PHPMailerAutoload.php';
            $mail = new PHPMailer;
            $mail->SMTPDebug = 4;                         
            $mail->isSMTP();                                     
            $mail->Host = 'smtp.zoho.com'; 
            $mail->SMTPAuth = true;                   
            $mail->Username   = " example@mydomain.com"; 
            $mail->Password   = "password";
            $mail->SMTPSecure = 'ssl';                          
            $mail->Port = 465;

            $mail->From = 'example';
            $mail->FromName = 'Doe';
            $mail->addAddress('sending address, 'John');     // Add a recipient              // Name is optional
            $mail->isHTML(true);                                  // Set email format to HTML
            $mail->Subject = 'Here is the subject';
            $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
            $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

            if(!$mail->send()) {
                echo 'Message could not be sent.';
                echo 'Mailer Error: ' . $mail->ErrorInfo;
            } else {
                echo 'Message has been sent';
            }
        ?>
    </body>
</html> 

 
Though it works perfectly on my localhost, it doesn't work from my server . (it has open ssl )
    • Sticky Posts

    • Important update! Re-authentication mandated for sensitive admin operations in Admin Console.

      Dear Zoho Mail Community, Hope you're all doing good and staying safe! As we strive to provide you with better security for your business email needs, an additional measure has been taken to ensure more security to the sensitive Admin Operations performed
    • Important announcement: IPv6 support in Inbound gateway

      Greetings from Zoho Mail team. We are happy to announce the support of IPv6 support for receiving emails in Zoho Mail. This post mainly addresses the admins who have configured inbound gateway for their organisation. As a part of the changes related to
    • Administrators now have permissions to access the Subscription and Payment details.

      Hello everyone! Hope you are all staying safe during these trying times. To ensure that your organization's email service, the backbone of communication, does not get affected due to inadvertent negligence by the super administrator, we have made a few changes in our roles and permissions to handle subscription and renewal smoothly. Earlier, any organization's Subscription and Payment information in Zoho Mail could be accessed only by the organization's Super Administrator. Now, based on requests
    • Move ahead from Docs to WorkDrive - WorkDrive is now available in all Workplace plans!

      Dear all,  We are glad to announce that WorkDrive is available across all the Workplace plans, with added storage and extensive team features.  Zoho WorkDrive is now available for all users, including those who subscribed before Zoho WorkDrive was introduced
    • Announcement - Changes in Custom login page

      In continuation to our efforts in protecting your Zoho Mail account we have made a few changes in the custom login page. We are making some enhancements in the browser to server communication to make it more secure.  You may be aware of the most of the modern web browsers mandate certain security practices to showing the webpages as 'Secure'.  We are rolling out the security related enhancements ensure that our custom login page accessed only in https mode and the authentication is securely done