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

Modules Perl Discussion :

Can't call method "mail" on an undefined value


Sujet :

Modules Perl

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    72
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2008
    Messages : 72
    Points : 41
    Points
    41
    Par défaut Can't call method "mail" on an undefined value
    Bonjour,

    j'ai telechargé un plugin nagios en perl. Lorsque j'essaye de l'executer, il me renvoie l'erreur:

    Can't call method "mail" on an undefined value at ./check_reporter line 318.

    J'ai lu plusieurs sujets a ce propos dans le forum, mais je n'ai malgré cela pas réussi a resoudre mon probleme.
    Je dois le faire marcher dans le cadre d'un stage, donc un coup de main serait vraiment apprécié!!

  2. #2
    Expert éminent
    Avatar de Jedai
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2003
    Messages
    6 245
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Avril 2003
    Messages : 6 245
    Points : 8 586
    Points
    8 586
    Par défaut
    Voyons, je sors ma boule de cristal... Je vois un objet dont l'initialisation s'est mal passée, je vois une méthode d'envoi d'email mal choisie... Et c'est tout.
    Sans élément supplémentaire, nous ne pourrons t'aider beaucoup plus que la simple traduction du message d'erreur.

    --
    Jedaï

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    72
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2008
    Messages : 72
    Points : 41
    Points
    41
    Par défaut
    Voici l'initialisation des variables et la partie du code ou a lieu l'erreur (je ne mets pas tout le code car il est assez long).

    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
    use strict;
    use Getopt::Long;
    use Net::SMTP;
    use LWP::UserAgent;
    use Date::Manip;
     
     
    my $mailhost    ='mac.com';                     #Fill these in!
    my $maildomain  ='mac.com';                             #Fill these in!
    my $mailfrom    ='pauline.danino@mac.com';              #Fill these in!
    my $mailto      ='pauline.danino@mac.com';              #Fill these in!
    my $timeout     =30;
    my $mailsubject ='';
    my $mailbody    ='';
     
    my $logfile     ='/usr/local/nagios/var/mail.log';      #Where would you like your logfile to live?
    my $debug       =1;                                     #Set the debug level to 1 or higher for information
     
    my $type        ='';
    my $repdateprev;
    my $reporturl;
     
    my $nagssbody;
    my $nagsssummary;
     
    my $webuser     ='nagios';                              #Set this to a read-only nagios user (not nagiosadmin!)
    my $webpass     ='nagios';                              #Set this to a read-only nagios user (not nagiosadmin!)
    my $webbase     ='http://demo.sportstec.fr/nagios/';    #Set this to the base of Nagios web page
    my $webcssembed =0;
     
    ---------------------------
     
    sub sendmail {
            my $smtp = Net::SMTP->new(
                    $mailhost,
                    Hello => $maildomain,
                    Timeout => $timeout,
                    Debug   => $debug,
            );
     
            $smtp->mail($mailfrom);
            $smtp->to($mailto);
     
            $smtp->data();
            $smtp->datasend("To: $mailto\n");
            $smtp->datasend("From: $mailfrom\n");
            $smtp->datasend("Subject: $mailsubject\n");
            $smtp->datasend("MIME-Version: 1.0\n");
            $smtp->datasend("Content-type: multipart/mixed; boundary=\"boundary\"\n");
            $smtp->datasend("\n");
            $smtp->datasend("This is a multi-part message in MIME format.\n");
            $smtp->datasend("--boundary\n");
            $smtp->datasend("Content-type: text/html\n");
            $smtp->datasend("Content-Disposition: inline\n");
            $smtp->datasend("Content-Description: Nagios report\n");
            $smtp->datasend("$mailbody\n");
            $smtp->datasend("--boundary\n");
            $smtp->datasend("Content-type: text/plain\n");
            $smtp->datasend("Please read the attatchment\n");
            $smtp->datasend("--boundary--\n");
     
            $smtp->dataend();
     
            $smtp->quit;

    L'erreur a lieu a la ligne $smtp->mail($mailfrom);

    Merci de ton aide.

  4. #4
    Membre actif Avatar de CKLN00
    Homme Profil pro
    Bioinformaticien Java/Perl
    Inscrit en
    Avril 2008
    Messages
    210
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Vienne (Poitou Charente)

    Informations professionnelles :
    Activité : Bioinformaticien Java/Perl
    Secteur : Santé

    Informations forums :
    Inscription : Avril 2008
    Messages : 210
    Points : 263
    Points
    263
    Par défaut

    et apparament à la ligne 318 que je devine (boule de cristale !) etre la suivante
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $smtp->mail($mailfrom);
    la variable $mailfrom est indéfinie
    CKL
    N°°b forever
    --
    may the be with you

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    72
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2008
    Messages : 72
    Points : 41
    Points
    41
    Par défaut
    Le fait qu'il y ait cette ligne au debut du code:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    my $mailfrom ='pauline.danino@mac.com'; #Fill these in!
    ne définit pas la variable $mailfrom????

  6. #6
    Expert éminent
    Avatar de Jedai
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2003
    Messages
    6 245
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Avril 2003
    Messages : 6 245
    Points : 8 586
    Points
    8 586
    Par défaut
    A mon avis, c'est plutôt $smtp qui n'est pas défini, son initialisation a dû mal se passer, autrement dit tu ne lui as pas passé une adresse correcte (je suppose que tu as bien rempli les champs "#Fill me in" ? mac.com ne ressemble pas à une adresse de serveur mail, c'est plutôt smtp.mac.com d'habitude).

    --
    Jedaï

Discussions similaires

  1. Réponses: 1
    Dernier message: 17/01/2007, 17h10
  2. Can't call method "mail" on an undefined value
    Par hpalpha dans le forum Modules
    Réponses: 2
    Dernier message: 18/01/2006, 10h50

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