Hi,
I’m trying to send an e-mail from a JSP application and I got this error
[QUOTE]
com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.1 Sender rejected: —– is not a valid from address
and here’s the test code I got after googling and after getting the SMTP server for my ISP:
[CODE]
String host=””;
String from = “”;
String to = “”;
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put(“mail.smtp.host”, host);
// Get session
Session session = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress(from));
// Set the to address
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
// Set the subject
message.setSubject(“Hello JavaMail”);
// Set the content
message.setText(“Welcome to JavaMail”);
// Send message
try{
Transport.send(message);
System.out.println(“message sent”);
}
catch(Exception e)
{
e.printStackTrace();
}
Any help would be appreciated.
Thanks.