je souhaite exécuté une class java qui envoi les email et utilise l'api javamail
pour cela j'ai installé un serveur smtp (agrosoft mail) en exécutant la class argosoft affiche le message suivant:
et voila le code source
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 27/05/2008 18:15:16 - ( 13) 220 ArGoSoft Mail Server Freeware, Version 1.8 (1.8.9.2) 27/05/2008 18:15:16 - ( 13) EHLO unicorni-dc5d36 27/05/2008 18:15:16 - ( 13) 250-Welcome [127.0.0.1], pleased to meet you 27/05/2008 18:15:16 - ( 13) 250-SIZE 5242880 27/05/2008 18:15:16 - ( 13) 250 HELP 27/05/2008 18:15:16 - ( 13) MAIL FROM:<aosiris@hotmail.com> 27/05/2008 18:15:16 - ( 13) 250 Sender "aosiris@hotmail.com" OK... 27/05/2008 18:15:17 - ( 13) RCPT TO:<23nwa@yahoo.com> 27/05/2008 18:15:17 - ( 13) 250 Recipient "23nwa@yahoo.com" OK... 27/05/2008 18:15:17 - ( 13) DATA 27/05/2008 18:15:17 - ( 13) 354 Enter mail, end with "." on a line by itself 27/05/2008 18:15:17 - Received 297 bytes 27/05/2008 18:15:17 - ( 13) 250 Message accepted for delivery. 27/05/2008 18:15:17 - ( 13) QUIT 27/05/2008 18:15:17 - ( 13) 221 Aba he 27/05/2008 18:15:17 - SMTP connection with 127.0.0.1 ended. ID=13
j'attend vos reponse pour m'aider a trouver ce problème
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 import java.util.*; import javax.mail.*; import javax.mail.internet.*; public class sendmessage { public static void main(String[] args) { if (args.length != 4) { System.out.println("usage: sendmessage <to> <from> <smtphost>" +"<true|false>"); System.exit(1); } boolean debug = false; // change to get more information String msgText = "A body.\nthe second ggggg."; String msgText2 = "Another body.\nmore lines."; boolean sendmultipart = Boolean.valueOf(args[3]).booleanValue(); // set the host Properties props = new Properties(); props.put("mail.smtp.host", args[2]); // create some properties and get the default Session Session session = Session.getDefaultInstance(props, null); session.setDebug(debug); try { // create a message Message msg = new MimeMessage(session); // set the from InternetAddress from = new InternetAddress(args[1]); msg.setFrom(from); InternetAddress[] address = {new InternetAddress(args[0])}; msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject("JavaMail APIs Test"); if (!sendmultipart) { // send a plain text message msg.setContent(msgText, "text/plain"); } else { // send a multipart message // create and fill the first message part MimeBodyPart mbp1 = new MimeBodyPart(); mbp1.setContent(msgText, "text/plain"); // create and fill the second message part MimeBodyPart mbp2 = new MimeBodyPart(); mbp2.setContent(msgText2, "text/plain"); // create the Multipart and its parts to it Multipart mp = new MimeMultipart(); mp.addBodyPart(mbp1); mp.addBodyPart(mbp2); // add the Multipart to the message msg.setContent(mp); } Transport.send(msg); } catch (MessagingException mex) { mex.printStackTrace(); } } }![]()
Partager