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

JavaScript Discussion :

Envoyer un mail en Javascript


Sujet :

JavaScript

  1. #1
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juin 2012
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Conseil

    Informations forums :
    Inscription : Juin 2012
    Messages : 76
    Points : 33
    Points
    33
    Par défaut
    bonjour,

    j'ai créer une formulaire html et je veux lorsque je clique sur le boutton envoyer m'envoie un mail dans ma boite,je sais pas comment le faire avec java ??

    voici mon code :

    Code html : 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
    <form method="" action="javascript:sendMail()" method="post">
        <table border="0" cellspacing="1">
            <tr>
                <td width="150"><p>Nom / Raison Social :<span style="color:red">*</span></p></td>
                <td width="395">
                    <input type="text" id="nom" size="59" style="background-color: #A9E2F3; color: rgb(255,255,255);font-weight: bold;"></td>
            </tr>
    		<tr>
                <td width="150"><p>Courriel :<span style="color:red">*</span></p></td>
                <td width="395">
                    <input type="text" id="courriel" size="59" style="background-color: #A9E2F3; color: rgb(255,255,255);font-weight: bold;"></td>
            </tr>
    		<tr>
                <td width="150"><p>Télephone : </p></td>
                <td width="395">
                    <input type="text" id="telephone" size="59" style="background-color: #A9E2F3; color: rgb(255,255,255);font-weight: bold;"></td>
            </tr>
            <tr>
                <td width="150"><p>Sujet :<span style="color:red">*</p></td>
                <td width="395">
                    <input type="text" id="edSubject" size="59" style="background-color: #A9E2F3; color: rgb(255,255,255);font-weight: bold;"></td>
            </tr>
            <tr>
                <td width="150"><p>Message :<span style="color:red">*</p></td>
                <td width="395">
                    <textarea rows="20" id="edBody" cols="55" style="background-color: #A9E2F3; color: rgb(255,255,255);font-weight: bold;overflow: hidden;"></textarea></td>
            </tr>
        </table>
        <br>
        <input type="submit" value="Envoyer" >
    </form>

    voici l code du javascript:

    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
    <script language="Javascript" type="text/javascript">
        function sendMail() {
            <!--Tester les donnees-->
            if (document.getElementById("nom").value.length==0) {
                alert("Saisir Votre Nom !!!");
                return;
            }
    		if (document.getElementById("prenom").value.length==0) {
                alert("Saisir Votre Prenom !!!");
                return;
            }
    		if (document.getElementById("courriel").value.length==0) {
                alert("Saisir Votre Mail !!!");
                return;
            }
    		if (document.getElementById("edSubject").value.length==0) {
                alert("Saisir le Sujet de Votre Message !!!");
                return;
            }
            if (document.getElementById("edBody").value.length==0) {
                alert("Ecrire le message !!!");
                return;
            }
            <!--Encoder l'url mailto-->
            return true;
        }
     
    </script>

  2. #2
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Points : 91 220
    Points
    91 220
    Billets dans le blog
    20
    Par défaut
    JavaScript ne peut heureusement pas envoyer d'e-mail...
    Sinon, n'importe quelle page pourrait se transformer rapidement en agent spammer !
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  3. #3
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juin 2012
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Conseil

    Informations forums :
    Inscription : Juin 2012
    Messages : 76
    Points : 33
    Points
    33
    Par défaut mail avec php
    bon voila j'ai essayer un autre truc mais ça marche pas!!

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <?php
    if($_submit) {
     
    $message="Nom: ".$nom."";
    $message="courriel: ".$courriel."";
    $message="telephone: ".$telephone."" ;
    $message="edSubject: ".$edSubject."" ;
    $message="edBody: ".$edBody."" ;
    $expediteur = "From: ".$email. "";
    $destinataire ="aouatif.elkhou@gmail.com";
    mail($destinataire,$message,$expediteur) ;
     
    }
    ?>

    Code html : 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
    <form action="contact.html"  method="post" >
        <table border="0" cellspacing="1">
            <tr>
                <td width="150"><p>Nom / Raison Social :<span style="color:red">*</span></p></td>
                <td width="395">
                    <input type="text" id="nom" name="nom"  size="59" style="background-color: #A9E2F3; color: rgb(255,255,255);font-weight: bold;"></td>
            </tr>
    		<tr>
                <td width="150"><p>Courriel :<span style="color:red">*</span></p></td>
                <td width="395">
                    <input type="text" id="courriel" name="courriel"  size="59" style="background-color: #A9E2F3; color: rgb(255,255,255);font-weight: bold;"></td>
            </tr>
    		<tr>
                <td width="150"><p>Télephone : </p></td>
                <td width="395">
                    <input type="text" id="telephone" name="telephone"  size="59" style="background-color: #A9E2F3; color: rgb(255,255,255);font-weight: bold;"></td>
            </tr>
            <tr>
                <td width="150"><p>Sujet :<span style="color:red">*</p></td>
                <td width="395">
                    <input type="text" id="edSubject"  name="edSubject" size="59" style="background-color: #A9E2F3; color: rgb(255,255,255);font-weight: bold;"></td>
            </tr>
            <tr>
                <td width="150"><p>Message :<span style="color:red">*</p></td>
                <td width="395">
                    <textarea rows="20" id="edBody"  name="edBody" cols="55" style="background-color: #A9E2F3; color: rgb(255,255,255);font-weight: bold;overflow: hidden;"></textarea></td>
            </tr>
        </table>

  4. #4
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Points : 91 220
    Points
    91 220
    Billets dans le blog
    20
    Par défaut
    Si ton formulaire pointe sur un fichier HTML, je vois mal comment tu peux exécuter du PHP.

    d'où sort cette variable ?
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  5. #5
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juin 2012
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Conseil

    Informations forums :
    Inscription : Juin 2012
    Messages : 76
    Points : 33
    Points
    33
    Par défaut
    je sais pas comment je dois résolu ce problème je suis totalement perturbé

  6. #6
    Membre à l'essai
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 22
    Points : 16
    Points
    16
    Par défaut
    En effet. Il te manque beaucoup de chose dans ton code à commencer par ton formulaire.
    Il manque ton bouton d'envoi (submit) et la balise de fin </form>.
    De plus ton formulaire devra renvoyer vers un fichier .php dont avec ton code php à quelques modifications près :

    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
    <?php
    if ($_POST['nom de ton bouton submit'])
    {
    $sujet="ton sujet"
    $message="<p>Nom: ".$nom.""</p>";
    $message.="<p>courriel: ".$courriel."</p>";
    $message.="<p>telephone: ".$telephone."</p>" ;
    $message.="<p>edSubject: ".$edSubject."</p>" ;
    $message.="<p>edBody: ".$edBody."</p>" ;
    $expediteur = "<p>From: ".$email. "</p>";
    $destinataire ="aouatif.elkhou@gmail.com";
    mail($destinataire,$sujet,$message,$expediteur) ;
     
    }
    ?>
    Voici quelques pistes en espérant que ça t'aidera

  7. #7
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 840
    Points : 9 224
    Points
    9 224
    Par défaut [HTA] SMTP Mail Client avec pièce jointe

    Si vous voulez envoyer un mail par vbscript avec un formulaire en HTA:

    SMTP Mail Client avec pièce jointe


Discussions similaires

  1. Peut-on envoyer un e-mail via Javascript ?
    Par MiJack dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 09/08/2007, 10h05
  2. Envoyer un mail avec Javascript
    Par HaTnuX dans le forum Général JavaScript
    Réponses: 23
    Dernier message: 22/02/2007, 08h44
  3. Envoyer un mail avec pièce jointe (javascript)
    Par Dorra_26 dans le forum Général JavaScript
    Réponses: 15
    Dernier message: 21/07/2006, 08h31
  4. [PERL/CGI] Envoyer un mail html/javascript
    Par LE NEINDRE dans le forum Web
    Réponses: 5
    Dernier message: 25/11/2005, 11h14
  5. envoyer un mail avec javascript
    Par robocop2776 dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 24/10/2005, 14h38

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