This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I have the java program to send an email. I have my mail.jar and activation.jar in the classpath. I have attached my output also with this thread. I am not sure. why the mail is not sent. It has not got into the Password Authenticator itself. Is it because the static usage. Can somebody help me out with how I can correct this program to send an email.
/**
* To store the email from address
*/
private String emailFromAddress;
/**
* To store the email list of recipients
*/
private String[] emailList;
/**
* To store the email subject
*/
private String emailSubject;
/**
* To store the SMTP host name
*/
private String smtpHostName;
/**
* To store the mail protocol
*/
private String mailProtocol;
/**
* To store the SMTP authentication value
*/
private String smtpAuth;
/**
* To store the SMTP port number
*/
private String smtpPort;
/**
* To store the SMTP authenticated user name
*/
private String smtpAuthUser;
/**
* To store the SMTP authenticated user password
*/
private String smtpAuthPwd;
/**
* This is called by the evaluate method to set From Address for sending mail
* @param emailFromAddress The email From Address to set.
*/
public void setEmailFromAddress(String emailFromAddress) {
this.emailFromAddress = emailFromAddress;
}
/**
* This is called by the evaluate method to set email List of recipients for sending mail
* @param emailList The email List of recipients to set.
*/
public void setEmailList(String[] emailList) {
this.emailList = emailList;
}
/**
* This is called by the evaluate method to set email Subject for sending mail
* @param emailSubject The email Subject to set.
*/
public void setEmailSubject(String emailSubject) {
this.emailSubject = emailSubject;
}
/**
* This is called by the evaluate method to set mail protocol used for sending mail
* @param mailProtocol The mail protocol used for sending mail to set.
*/
public void setMailProtocol(String mailProtocol) {
this.mailProtocol = mailProtocol;
}
/**
* This is called by the evaluate method to set SMTP Authentication for sending mail
* @param smtpAuth The SMTP Authentication to set.
*/
public void setSmtpAuth(String smtpAuth) {
this.smtpAuth = smtpAuth;
}
/**
* This is called by the evaluate method to set SMTP Authentication Password for sending mail
* @param smtpAuthPwd The SMTP Authentication Password to set.
*/
public void setSmtpAuthPwd(String smtpAuthPwd) {
this.smtpAuthPwd = smtpAuthPwd;
}
/**
* This is called by the evaluate method to set SMTP Authentication User Name for sending mail
* @param smtpAuthUser The SMTP Authenticated User Name to set.
*/
public void setSmtpAuthUser(String smtpAuthUser) {
this.smtpAuthUser = smtpAuthUser;
}
/**
* This is called by the evaluate method to set SMTP Host Name for sending mail
* @param smtpHostName The SMTP Host Name to set.
*/
public void setSmtpHostName(String smtpHostName) {
this.smtpHostName = smtpHostName;
}
/**
* This is called by the evaluate method to set SMTP Port number for sending mail
* @param smtpPort The SMTP Port number to set.
*/
public void setSmtpPort(String smtpPort) {
this.smtpPort = smtpPort;
}
public PasswordAuthentication getPasswordAuthentication()
{
System.out.println("authentication1111111111");
String username = "corporate email id"; // we use outlook email. I have given my corporate email id
String password = "password";// the corresponding password
System.out.println("authentication&&&&&&&&&");
return new PasswordAuthentication(username, password);
}
}
}
OUTPUT
=====
Hello World!
BEFORE
oNE
three
DEBUG: JavaMail version 1.4ea
DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.5.0_15\jre\lib\
javamail.providers (The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax
.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsyste
ms, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com
.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLSt
ore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsyst
ems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.su
n.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=jav
ax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc],
com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP
3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.
sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STOR
E,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Prov
ider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc],
pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems
, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun
Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.S
MTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.5.0_15\jre\lib\
javamail.address.map (The system cannot find the file specified)
TWO
after session
after the from
hello
hi
plain
Cheers,<br />Geetha
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35249
7
posted
0
Please edit your post to UseCodeTags, so that the code is shown in a more structured way. It's unnecessarily hard to read as it is.
I modified my smtp.mail.auth to true. Now its going into Authenticator. But I dont see the mail delivered to the gmail address (I have given valid gmail address) given. Transport.Send is not happening. Kindly pleass help me what should I change in program?