Bonjour,
Quelle est la commande svp pour envoyer un mail dans fichier Batch ?
J'ai essayé cette commande:
Mais mon OS (Win2003) ne reconnait pas la commande sendmail.exe.Code:sendmail.exe -f mon_nom@adresse destinataire@adresse < toto.log
Merci.
Version imprimable
Bonjour,
Quelle est la commande svp pour envoyer un mail dans fichier Batch ?
J'ai essayé cette commande:
Mais mon OS (Win2003) ne reconnait pas la commande sendmail.exe.Code:sendmail.exe -f mon_nom@adresse destinataire@adresse < toto.log
Merci.
Salut,
ce sont des commandes externes elle ne sont pas natives à windows,
moi perso j'utilise Blat.exe
Amicalement
:salut:
Inspirez-vous de cette discussion : Envoyer un mail avec BLAT :king:
Bonjour && Merci.
Je suis sous XP PRO, blat n'est pas reconnu....
@+Code:
1
2 'blat' n'est pas reconnu en tant que commande interne ou externe, un programme exécutable ou un fichier de commandes.
Avez-vous télécharger au moins Blat.exe :koi:
C'est une commande externe à télécharger http://www.blat.net/ ;)
http://sourceforge.net/projects/blat...ull%20Version/
Bonjour Mehdi,
Ja' installé:
Mais en testant mauvaise surprise:Code:
1
2
3
4
5 blat -install monserver_messagerie.FR agdid04@xxxx.fr Blat v2.6.2 w/GSS encryption (build : Feb 25 2007 12:06:19) SMTP server set to monserver_messagerie.FR on port 25 with user agdid04@xxxx.fr , retry 1 time(s)
Merci.Code:
1
2
3
4
5
6
7
8
9 C:\>blat c:\tstst.txt -s TESTBALT -to agdid04@xxxx.fr Blat v2.6.2 w/GSS encryption (build : Feb 25 2007 12:06:19) Sending c:\tstst.txt to agdid04@xxxx.fr Subject: TESTBALT Login name is agdid04@xxxx.fr The SMTP server does not like the sender name. Have you set your mail address correctly? Error: Connection to server was dropped.
@+
:salut:
essayez exactement cette manip http://www.developpez.net/forums/d13...i/#post7345553
et dis-moi le résultat
Bonjour Mehdi,
C'est mon server Exchange qui bloquerait l'envoi.
Merci.Code:The SMTP server does not like the sender name.
@+
:salut:
Donc vous avez réussi à envoyer un mail depuis BLAT ou Non :koi:
Non pas encore ... je regarde côté mon server Outlook ...
merci.
@+
Ok, Merci je vais essayer avec gmail.
@+
:salut:
Vous pouvez envoyer vos mails en utilisant le serveur smtp de gmail (smtp.gmail.com) avec vos identifiants et ça marche pour toujours sans aucun problème :king:
Remarque : changer juste ou j'ai fait les commentaires (à changer) Source
GmailSender.vbs
Code:
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
56Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). Const cdoAnonymous = 0 'Do not authenticate Const cdoBasic = 1 'basic (clear-text) authentication Const cdoNTLM = 2 'NTLM Set objMessage = CreateObject("CDO.Message") objMessage.Subject = "Example CDO Message" objMessage.From = """Me"" <test@gmail.com>" objMessage.To = "votreAdresse@mail.com" 'à changer objMessage.HTMLBody = "<H1>Ceci est exemple d'envoi mail ...</H1><br><h2>It was sent using SMTP authentication and SSL.</h2>" '==This section provides the configuration information for the remote SMTP server. objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Name or IP of Remote SMTP Server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'Type of authentication, NONE, Basic (Base64 encoded), NTLM objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic 'Your UserID on the SMTP server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "TonLogin@gmail.com" ' à changer 'Your password on the SMTP server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "TonPass" 'à changer 'Server port (typically 25) objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'Use SSL for the connection (False or True) objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True 'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server) objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 objMessage.Configuration.Fields.Update '==End remote SMTP server configuration section== On Error Resume Next objMessage.Send If err<> o Then Msgbox Err.Description,vbCritical,Err.Description else MsgBox "Message envoyé avec succés !",VbInformation,"Message envoyé avec succés !" end if
j'ai essayé avec plusieurs exemple mais ça ne marche toujours pas !!
voici l'un d'eux :
et voici l'erreur :Code:
1
2 blat test.log -server smtp.gmx.com -to dest@gmail.com -f address@gmail.com -s "test mail" -u "address@gmail.com" -pw "password" -debug -log envois-mails.log -timestamp
Code:
1
2
3
4
5
6
7
8
9
10
11
12
132014.07.23 14:07:26 (Wed): <<<getline<<< 535 Authentication credentials invalid 2014.07.23 14:07:26 (Wed): The SMTP server did not accept Auth PLAIN value. Are your login userid and password correct? 2014.07.23 14:07:26 (Wed): >>>putline>>> AUTH LOGIN 2014.07.23 14:07:26 (Wed): <<<getline<<< 334 VXNlcm5hbWU6 2014.07.23 14:07:26 (Wed): >>>putline>>> b3Vzcy56YWltQGdtYWlsLmNvbQ== 2014.07.23 14:07:26 (Wed): <<<getline<<< 334 UGFzc3dvcmQ6 2014.07.23 14:07:26 (Wed): >>>putline>>> aG90bWFpbGhvdG1haWw= 2014.07.23 14:07:26 (Wed): <<<getline<<< 535 Authentication credentials invalid 2014.07.23 14:07:26 (Wed): The SMTP server did not accept Auth LOGIN PASSWD value. 2014.07.23 14:07:26 (Wed): >>>putline>>> QUIT 2014.07.23 14:07:26 (Wed): <<<getline<<< 221 gmx.com Service closing transmission channel
Pour utiliser BLAT avec Gmail il te faut utiliser Stunnel.
Gmail requiert apparemment une connexion (SSL).
Pour ce faire télecharger Stunnel
Editer le stunnel.conf
et remplacer son contenu par :
Ensuite on lançe Stunnel comme service.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 # GLOBAL OPTIONS client = yes output = stunnel-log.txt debug = 0 taskbar = no # SERVICE-LEVEL OPTIONS [SMTP Gmail] accept = 127.0.0.1:1099 connect = smtp.gmail.com:465 [POP3 Gmail] accept = 127.0.0.1:1109 connect = pop.gmail.com:995
Puis on cree une entré dans le registre avec toute les valeurs dont on aura besoin plus tard (dans ton BAT) :
Donc en ligne de commande on écris ceçi avec les bonne valeur (ID et MDP)
maintenant on écris un fichier BAT avec ceçi dedans :Code:blat -install smtp.gmail.com ton_adresse_e_mail@gmail.com -u Nom_utilisateur -pw Motdepasse – - gmailsmtp
Envoiemail.bat :
Code:
1
2 @echo off c:\windows\blat.exe -p gmailsmtp -to ton_adresse_E-Mail@gmail.com -subject "Test envoi" -body %1 -server 127.0.0.1:1099
Et dans le prompt ou depuis un autre BAT tu lançes ton bat avec comme argument le message à envoyer .
Exemple :
EnvoieMail.bat "Test d'envoi d'un mail"
Tu peux également remplacer le sujet par une variable (ici "Test d'envoi")
PS :
Synthaxe des commandes BLAT : http://www.blat.net/syntax/syntax.html
Vous pouvez aussi utiliser un autre compte E-Mail comme GMX qui n'a pas besoin de connection SSL et qui fonctionnera donc sans Stunnel. (Perso c'est ce que j'ai fait)
;)