Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
msgsend sample Program with JavaMail 1.5.4
What is the msgsend.java in javamail-samples.zip? I downloaded it together with javax.mail-1.5.4.jar.
✍: FYIcenter.com
msgsend.java in javamail-samples.zip is a sample program that sends out a simple text email message through a SMTP server.
If you downloaded and installed javamail-samples.zip together with javax.mail-1.5.4.jar, folderlist.java is located at \local\javamail-1.5.4\javamail-samples\msgsend.java. Below is the usage description of msgsend.java:
Description: Send a simple text message. Optionally saves a copy of the outgoing message in a folder (record-folder). Most parameters to this program are optional. When the program is run, it interactively asks for the "To" and "Subject" fields if not already available. Then the program expects the body of the message. After you type in the body, hit Ctrl-D on Unix systems or Ctrl-Z on Windows systems to send the message. Usage: java msgsend -L <store-url> -T <protocol> -H <host> -U <user> -P <passwd> -s <subject> -o <from> -c <cc> -b <bcc> -f <record> -M <smtphost> [-d] <to> Options: -L <store-url> : URL of the store for the record-folder -T <protocol> : If <store-url> is not present, this indicates the store protocol for the record-folder. -H <host> : If <store-url> is not present, this indicates the hostname for the record-folder. -U <user> : If <store-url> is not present, this indicates the username for the record-folder. -P <passwd> : If <store-url> is not present, this indicates the password for the record-folder. -f <record> : name of record-folder. -M <smtphost> : Host name of SMTP server. Defaults to "localhost" which often works on UNIX but rarely on Windows. -s <subject> : Subject of message to be sent -o <from> : From address of message to be sent -c <cc> : Cc address of message to be sent -b <bcc> : Bcc address of message to be sent -d : Turn on session debugging. -a <file> : Include file as an attachment with the message Argument: <to> : To address of message to be sent
Here is an execution session of msgsend.java:
fyicenter>cd \local\javamail-1.5.4\javamail-samples local\javamail-1.5.4\javamail-samples>java -version java version "1.8.0_45" local\javamail-1.5.4\javamail-samples>javac -cp .;..\javax.mail-1.5.4.jar msgsend.java local\javamail-1.5.4\javamail-samples>java -cp .;..\javax.mail-1.5.4.jar msgsend -d -M smtp.junkmail.com john@yahoo.com To: john@yahoo.com Subject: Testing SMTP with JavaMail 1.5.4 DEBUG: setDebug: JavaMail version 1.5.4 Hi there! ^Z DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.s mtp.SMTPTransport,Oracle] DEBUG SMTP: useEhlo true, useAuth false DEBUG SMTP: trying to connect to host "smtp.junkmail.com", port 25, isSSL false com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.jun kmail.com, 25; timeout -1; nested exception is: java.net.UnknownHostException: smtp.junkmail.com at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2054) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:69 7) at javax.mail.Service.connect(Service.java:364) at javax.mail.Service.connect(Service.java:245) at javax.mail.Service.connect(Service.java:194) at javax.mail.Transport.send0(Transport.java:253) at javax.mail.Transport.send(Transport.java:124) at msgsend.main(msgsend.java:188)
The output shows that:
⇒ Run msgsend.java 1.5.4 with Gmail SMTP Server
⇐ Run folderlist.java 1.5.4 with Gmail SSL POP3
2016-01-13, 2744🔥, 0💬
Popular Posts:
Rhino JavaScript Java Library is an open-source implementation of JavaScript written entirely in Jav...
What Is fop.jar? I got it from the fop-2.7-bin.zip. fop.jar in fop-2.7-bin.zip is the JAR file for F...
What Is commons-net-ftp-2.0.jar? commons-net-ftp-2.0.jar is the JAR file for Apache Commons Net FTP ...
What is ojdbc.jar - JDBC Driver for Oracle? ojdbc.jar is a JDBC driver from Oracle that provides dat...
Where to find answers to frequently asked questions on Downloading and Using JDK (Java Development K...