IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Librairie php-ews lire des mails Excahnge 2010


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé Avatar de Mika2008
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    176
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2007
    Messages : 176
    Par défaut Librairie php-ews lire des mails Excahnge 2010
    Bonjour,

    Lien vers la librairie : https://github.com/jamesiarmes/php-ews


    j'ai trouvé cette librairie, qui à l'air très intéressante et qui permet de lire des mails sur un exchange 2010, en utilisant les webservices exchange.

    c'est exactement ce que je voulais, sauf que

    le problème c'est que je n'arrive pas à l'utiliser
    Fatal error: Uncaught exception 'EWS_Exception' with message 'SOAP client returned status of 401
    donc j'utilise le code suivant pour essayer de faire

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    <?php
     
    //require_once 'php-ews/EWSAutodiscover.php';
    require_once 'php-ews/EWS_Exception.php';
    //require_once 'php-ews/EWSType.php';
    //require_once 'php-ews/ExchangeWebServices.php';
    //require_once 'php-ews/NTLMSoapClient.php';
    //require_once 'php-ews/NTLMSoapClient.php';
    //require_once 'php-ews/EWSType/FindFolderType.php';
    //require_once 'php-ews/EWSType/FolderQueryTraversalType.php';
    //require_once 'php-ews/EWSType/FolderResponseShapeType.php';
    //require_once 'php-ews/EWSType/DefaultShapeNamesType.php';
    //require_once 'php-ews/EWSType/IndexedPageViewType.php';
    //require_once 'php-ews/EWSType/NonEmptyArrayOfBaseFolderIdsType.php';
    //require_once 'php-ews/EWSType/DistinguishedFolderIdType.php';
    //require_once 'php-ews/EWSType/DistinguishedFolderIdNameType.php';
    require_once 'php-ews/NTLMSoapClient/Exchange.php';
     
     
    /**
     * Function to autoload the requested class name.
     * 
     * @param string $class_name Name of the class to be loaded.
     * @return boolean Whether the class was loaded or not.
     */
    function __autoload($class_name)
    {
        // Start from the base path and determine the location from the class name,
        $base_path = 'php-ews/';
        $include_file = $base_path . '/' . str_replace('_', '/', $class_name) . '.php';
     
        return (file_exists($include_file) ? require_once $include_file : false);
    }
     
     
    __autoload("FindFolderType");
     
     
    $email= "*************************";
    $username ="***********";
    $password ="**";
    $server = "***********";
     
    $ews = new ExchangeWebServices($server, $email, $password);
     
    if ($ews == True )
    	echo "C'est good</br>";
    else
    	echo "it's not good</br>";
     
    // start building the find folder request
    $request = new EWSType_FindFolderType();
    $request->Traversal = EWSType_FolderQueryTraversalType::SHALLOW;
    $request->FolderShape = new EWSType_FolderResponseShapeType();
    $request->FolderShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
     
    // configure the view
    $request->IndexedPageFolderView = new EWSType_IndexedPageViewType();
    $request->IndexedPageFolderView->BasePoint = 'Beginning';
    $request->IndexedPageFolderView->Offset = 0;
     
    // set the starting folder as the inbox
    $request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
    $request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
    $request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX;
     
    // make the actual call
    $response = $ews->FindFolder($request);
    echo '<pre>'.print_r($response, true).'</pre>';
    ?>

    voici le résultat que j'ai :

    C'est good
    Fatal error: Uncaught exception 'EWS_Exception' with message 'SOAP client returned status of 401' in /var/www/php-ews/php-ews/ExchangeWebServices.php:729 Stack trace: #0 /var/www/php-ews/php-ews/ExchangeWebServices.php(379): ExchangeWebServices->processResponse(NULL) #1 /var/www/php-ews/index.php(68): ExchangeWebServices->FindFolder(Object(EWSType_FindFolderType)) #2 {main} thrown in /var/www/php-ews/php-ews/ExchangeWebServices.php on line 729

    qu'en pensez vous svp ?

  2. #2
    Membre Expert

    Profil pro
    Inscrit en
    Mai 2008
    Messages
    1 576
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 1 576
    Par défaut
    Ça semble être un problème fréquent, lié à une version incompatible de cURL. Que dit curl -V ?
    Selon le readme:
    cURL with NTLM support (7.23.0+ recommended)

  3. #3
    Membre confirmé Avatar de Mika2008
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    176
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2007
    Messages : 176
    Par défaut
    Bonjour,

    merci de ta réponse :

    voici ma version de curl :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    [/var/www/php-ews] > curl -V
    curl 7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
    Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp smtp smtps telnet tftp 
    Features: GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
    merci je vais chercher comment mettre à jour ma version de curl.

  4. #4
    Membre Expert

    Profil pro
    Inscrit en
    Mai 2008
    Messages
    1 576
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2008
    Messages : 1 576
    Par défaut
    Juste au cas où, est-ce que l'identifiant et le mot de passe marchent en accès web?

  5. #5
    Membre confirmé Avatar de Mika2008
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    176
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2007
    Messages : 176
    Par défaut
    Citation Envoyé par Tsilefy Voir le message
    Juste au cas où, est-ce que l'identifiant et le mot de passe marchent en accès web?


    oui j'ai testé avec le lien que j'ai mis dans $server, en directe et ça fonctionne.

    directement dans le navigateur

  6. #6
    Membre confirmé Avatar de Mika2008
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    176
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2007
    Messages : 176
    Par défaut
    bon j'ai pas encore trouvé comment mettre à jour la lib curl sur mon serveur, mais j'ai trouvé un bon de code qui fonctionne :


    http://blog.ianty.com/ubuntu/exchang...mv2-and-linux/

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    <?php
     
    $host = 'foo.ews-host.com';
    $username = 'username'; // just need the name, no domain, nothing else
    $password = 'password';
    $ch = curl_init('https://'.$host.'/ews/services.wsdl'); 
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
    curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
    $response = curl_exec($ch);
    $info = curl_getinfo( $ch );
    $error =  curl_error ($ch);
    print_r(array($response,$info,$error));

    mais bon du coup faut que je recrée ma lib ews

Discussions similaires

  1. Lire des mails dans Outlook Express
    Par G_angel dans le forum C#
    Réponses: 1
    Dernier message: 02/03/2010, 11h23
  2. Recevoir / lire des mails
    Par capit030 dans le forum VC++ .NET
    Réponses: 1
    Dernier message: 16/12/2009, 13h41
  3. Réponses: 15
    Dernier message: 11/07/2008, 15h21
  4. [Excel] Comment lire des fichiers excel avec php?
    Par dear_rihab dans le forum Bibliothèques et frameworks
    Réponses: 5
    Dernier message: 02/11/2007, 12h38
  5. Réponses: 3
    Dernier message: 04/09/2007, 15h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo