PHP code example of sergpopov / cloudmailruphp

1. Go to this page and download the library: Download sergpopov/cloudmailruphp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sergpopov / cloudmailruphp example snippets




use SergPopov\CloudMailRu\CloudMailRu;
use SergPopov\CloudMailRu\CloudMailRuException;

$username = 'username'; // учетная запись username
$domain = 'mail.ru';
$password = 'password';

$pathLocalFile = __DIR__.'/testfile.txt';
$pathFileOnCloud = '/testdir/testfile.txt';

$cloud = new CloudMailRu($username, $domain, $password);
try {
    $url = $cloud->login()
        ->fileRemove($pathLocalFile)
        ->fileUpload($pathLocalFile, $pathFileOnCloud)
        ->filePublish($pathFileOnCloud);
    var_dump($url);
} catch (CloudMailRuException $e) {
    echo $e->getMessage();
}