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

Ext JS / Sencha Discussion :

envoi d'un mail via un formulaire


Sujet :

Ext JS / Sencha

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    491
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 491
    Par défaut envoi d'un mail via un formulaire
    Bonjour,

    j'ai un formulaire, qui doit me permettre d'envoyer un mail quand je clique sur un bouton, voici mon code :
    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
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    Ext.ns('PI');
    	PI.wContact = Ext.extend(Ext.Window, {
    			initComponent : function() {
     
    			var contact = {
    					xtype:'form'
    					,id: 'mail-form'
    					,url:'scripts/sendMail.php'
    					,frame:true 
    					,defaults:{anchor:'95%'} 
    					,items:[{
    						xtype: 'textfield'
    						,id: 'contactEmail'
    						,vtype: 'email'
    						,fieldLabel: 'Votre e-mail'
    						,allowBlank: false
    						,msgTarget: 'side'
    						,blankText: 'e-mail non valide'
    						},
    						{
    						xtype: 'textfield'
    						,id: 'contactObjet'
    						,fieldLabel: 'Objet'
    						,allowBlank: false
    						,msgTarget: 'side'
    						},
    						{
    						xtype: 'textarea'
    						,id: 'contactMsg'
    						,height: 350
    						,hideLabel: true
    						,allowBlank: false
    						,msgTarget: 'side'
    						}
    					]
    					,buttonAlign: 'center' 
    					,buttons: [
    						{
    						xtype: 'button'
    						,text: 'Envoyer'
    						,icon: 'img/email_go.png'
    						,bubbleEvents: ['envoyer']
    						,handler: function(){this.fireEvent('envoyer');}
    						},{
    						xtype: 'button'
    						,text: 'Annuler'
    						,icon: 'img/cross.png'
    						,bubbleEvents: ['annuler']
    						,handler: function(){this.fireEvent('annuler');}
    						}
    					]
     
    			};
     
    			var config = {
    				id: 'wContact'
    				,itemId: 'wContact'
    				,width: 750
    				,height: 500
    				,minWidth: 300
    				,minHeight: 200
    				,layout: 'fit' 
    				,border: false 
    				,frame: true 
    				,title: 'Contact' 
    				,items: [contact]
    				}	// fin config
     
     
    			// apply config
    			Ext.apply(this, Ext.apply(this.initialConfig, config));
     
    			// call parent
    			PI.wContact.superclass.initComponent.apply(this, arguments);
    			this.show();
    			}	// fin function initComponent
    			,listeners: {
    				envoyer : function() {
    						Ext.getCmp('mail-form').getForm().submit();
    						this.close();
    				}
    				,annuler : function() {this.close();}
    			}
     
    	}); 	// fin PI.wContact
     
     
     
    	Ext.reg('wContact', PI.wContact);
    Quand je clique sur envoyer, la fenetre se ferme bien, mais je ne reçois jamais de mail.
    et comment passer les paramètres saisis dans les champs du formulaire au script php ?
    le script php d'envoi de mail fonctionne bien quand je le lance seul, je reçois bien un mail.

    qu'est ce qui cloche?

    Merci,

    Nicolas

  2. #2
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    491
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 491
    Par défaut
    Bon, j'arrive maintenant à envoyer un mail avec ce code :
    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
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
     
    Ext.ns('ObsIUEM');
    	ObsIUEM.wContact = Ext.extend(Ext.Window, {
    			initComponent : function() {
     
    			var contact = new Ext.form.FormPanel({
    					xtype:'form'
    					,id: 'mail-form'
    					,frame:true 
    					,monitorValid:true
    					,defaults:{anchor:'95%'} 
    					,items:[{
    						xtype: 'textfield'
    						,id: 'contactEmail'
    						,vtype: 'email'
    						,fieldLabel: 'Votre e-mail'
    						,allowBlank: false
    						,msgTarget: 'side'
    						,blankText: 'e-mail non valide'
    						},
    						{
    						xtype: 'textfield'
    						,id: 'contactObjet'
    						,fieldLabel: 'Objet'
    						,allowBlank: false
    						,msgTarget: 'side'
    						},
    						{
    						xtype: 'textarea'
    						//xtype: 'htmleditor'
    						,id: 'contactMsg'
    						,height: 350
    						,hideLabel: true
    						,allowBlank: false
    						,msgTarget: 'side'
    						}
    					]
    					,buttonAlign: 'center' 
    					,buttons: [
    						{
    						xtype: 'button'
    						,text: 'Envoyer'
    						,icon: 'img/email_go.png'
    						,formBind:true
    						,bubbleEvents: ['envoyer']
    						,handler: function(){this.fireEvent('envoyer');}
    						},{
    						xtype: 'button'
    						,text: 'Annuler'
    						,icon: 'img/cross.png'
    						,bubbleEvents: ['annuler']
    						,handler: function(){this.fireEvent('annuler');}
    						}
    					]
     
    			});
     
    			var config = {
    				id: 'wContact'
    				,itemId: 'wContact'
    				,width: 750
    				,height: 500
    				,minWidth: 300
    				,minHeight: 200
    				,layout: 'fit' 
    				,border: false 
    				,frame: true 
    				,title: 'Contact' 
    				,items: [contact]
    				}	// fin config
     
     
    			// apply config
    			Ext.apply(this, Ext.apply(this.initialConfig, config));
     
    			// call parent
    			ObsIUEM.wContact.superclass.initComponent.apply(this, arguments);
    			this.show();
    			}	// fin function initComponent
    			,listeners: {
    				envoyer : function() {
    						Ext.getCmp('mail-form').getForm().submit({
    										url: 'scripts/sendMail.php?from='+Ext.getCmp('contactEmail').getValue()+
    													'&subject='+Ext.getCmp('contactObjet').getValue()+
    													'&msg='+Ext.getCmp('contactMsg').getValue(),
    										method:  'POST',
    										self: self,
    										scope: this});
    						this.close();
    				}
    				,annuler : function() {this.close();}
    			}
     
    	}); 	// fin ObsIUEM.wContact
     
     
     
    	Ext.reg('wContact', ObsIUEM.wContact);

    il reste juste une petite chose :
    J'ai mis sur mes 3 champs (email, objet, message) la propriété allowBlank=false et la propriété formBind=true sur le bouton Envoyer.
    Et donc, mon bouton Envoyer ne devient actif que si mes 3 champs sont remplis.
    Mais si je remplace mon champ message (type textarea) par un champ de type htmleditor, la propriété allowBlank n'est pas prise en compte sur ce champ, et donc mon bouton Envoyer devient actif dès que les champs email et objet sont remplis.
    Pourquoi?

    Merci,

    Nico

Discussions similaires

  1. Envoie mail via tuto formulaire slide
    Par manusimon dans le forum jQuery
    Réponses: 1
    Dernier message: 29/01/2010, 10h45
  2. Envoi de mail via un formulaire
    Par zizou86 dans le forum Langage
    Réponses: 2
    Dernier message: 19/05/2008, 12h27
  3. Envoi d'un mail via outlook avec l'option de vote
    Par Djohn dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 18/03/2008, 11h23
  4. Envoie d'e-mail via apache
    Par Mister_FX dans le forum Apache
    Réponses: 2
    Dernier message: 25/01/2007, 17h28

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