Posted By:
Anonymous
Posted On:
Wednesday, January 1, 2003 07:36 PM
import java.util.*; import java.io.*; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; class Authenticator { public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("userid", "password"); } } public class sms { public static void main(String[] args) throws Exception { String messageBody = "testing 123"; int x; String strEmailAddress = "userid@yahoo.com"; String strSmtpServer = "smtp.mail.yahoo.com"; String to = strEmailAddress; String from
More>>
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
class Authenticator
{
public PasswordAuthentication
getPasswordAuthentication()
{
return new PasswordAuthentication("userid", "password");
}
}
public class sms
{
public static void main(String[] args)
throws Exception {
String messageBody = "testing 123";
int x;
String strEmailAddress = "userid@yahoo.com"; String strSmtpServer = "smtp.mail.yahoo.com";
String to = strEmailAddress;
String from ="userid@yahoo.com";
String host = strSmtpServer;
Properties props = new Properties();
props.put("mail.smtp.host", host);
Authenticator auth = new Authenticator();
Session session = Session.getDefaultInstance(props,auth);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("i miss u");
msg.setSentDate(new java.util.Date());
msg.setText(messageBody );
Transport.send(msg);
}
}
my problem
i get an error
cannot resolve symbol
symbol : method getDefaultInstance (java.util.Properties,Authenticator)
location: class javax.mail.Session
Session session = Session.getDefaultInstance(props,auth);
how to i authenticate my user id when i wan to send my mail?? i really need help here...thanks
<<Less