SMTP客户端Java程序 [英] SMTP client Java program
问题描述
我对Java Mail完全不熟悉。我首先想要执行该程序(我通过我的老年人),看看是否一切正常。因此,当我编译该代码时,我发现错误,找不到Java邮件的所有类和包。
有谁可以列出我的程序编译和执行所需的东西没有任何问题。我下载了JAva Mail 1.4.5,但是没有安装文件?
我有JAva 1.6和Windows XP
请帮助........
错误:
C:> javac SMTPClient.java
SMTPClient.java:2:包javax.mail不存在
import javax.mail。;
^
SMTPClient.java:3:包javax.mail.internet不存在
import javax.mail.internet。;
^
SMTPClient.java:18:找不到符号
符号:class Session
location:class SMTPClient
Session session = Session.getDefaultInstance(properties);
^
SMTPClient.java:18:找不到符号
符号:变量会话
位置:类SMTPClient
会话会话= Session.getDefaultInstance(properties);
^
SMTPClient.java:21:找不到符号
符号:class MimeMessage
location:class SMTPClient
MimeMessage message = new MimeMessage(session);
^
SMTPClient.java:21:找不到符号
符号:class MimeMessage
location:class SMTPClient
MimeMessage message = new MimeMessage(session);
^
SMTPClient.java:25:找不到符号
符号:class InternetAddress
location:class SMTPClient
message.setFrom(new InternetAddress(from));
^
SMTPClient.java:28:包邮件不存在
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
I am totally new to Java Mail. I first wanted to execute the program (which i had through my seniors )and see whether everything is working fine. So when i compile that code i get errors with all the class and packages of Java mail being not found.
Could anyone please list out the things that i need for my program to compile and execute without any problems. I had downloaded the "JAva Mail 1.4.5" but there was no installer file in that?
I have JAva 1.6 and Windows XP
Please Help........
Errors : C:>javac SMTPClient.java
SMTPClient.java:2: package javax.mail does not exist
import javax.mail.;
^
SMTPClient.java:3: package javax.mail.internet does not exist
import javax.mail.internet.;
^
SMTPClient.java:18: cannot find symbol
symbol : class Session
location: class SMTPClient
Session session = Session.getDefaultInstance(properties);
^
SMTPClient.java:18: cannot find symbol
symbol : variable Session
location: class SMTPClient
Session session = Session.getDefaultInstance(properties);
^
SMTPClient.java:21: cannot find symbol
symbol : class MimeMessage
location: class SMTPClient
MimeMessage message = new MimeMessage(session);
^
SMTPClient.java:21: cannot find symbol
symbol : class MimeMessage
location: class SMTPClient
MimeMessage message = new MimeMessage(session);
^
SMTPClient.java:25: cannot find symbol
symbol : class InternetAddress
location: class SMTPClient
message.setFrom(new InternetAddress(from));
^
SMTPClient.java:28: package Message does not exist
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
^
SMTPClient.java:28 :找不到符号
符号:class InternetAddress
location:class SMTPClient
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
SMTPClient.java:28: cannot find symbol symbol : class InternetAddress location: class SMTPClient message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
^
SMTPClient.java:40 :找不到符号
符号:class Transport
location:class SMTPClient
Transport t = session.getTransport(smtps);
^
10个错误
SMTPClient.java:40: cannot find symbol symbol : class Transport location: class SMTPClient Transport t = session.getTransport("smtps"); ^ 10 errors
C:>
推荐答案
下载java mail.jar和security.jar
Download the java mail.jar and security.jar
1.将以下代码复制到记事本并保存为EmailAgent.java(相应地更改电子邮件地址和密码)
1.Copy the below code to notepad and save as EmailAgent.java (change the email adresses and password accordingly)
-
Go要运行,请键入cmd并按Enter键
Go to run, type cmd and press enter
导航到保存EmailAgent.java文件的路径。
Navigate to path where EmailAgent.java file is saved.
将mail.jar和security.jar复制到保存EmailAgent.java的同一目录
Copy your mail.jar and security.jar to the same directory where EmailAgent.java is saved
编译java文件
javac -cp .; mail.jar; security.jar EmailAgent.java
javac -cp .;mail.jar;security.jar EmailAgent.java
运行已编译的java类
Run compiled java class
java -cp .; mail.jar; security.jar EmailAgent
java -cp .;mail.jar;security.jar EmailAgent
并检查您的sendTo电子邮件地址收件箱..宾果:)
And check your sendTo email address inbox.. Bingo :)
这篇关于SMTP客户端Java程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!