Hi all,
Below is the code for sending the e-mail, getting the errors as written below the program
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SendApp {
public static void send(
String smtpHost, int smtpPort,String from, String to,String subject, String content) throws AddressException, MessagingException {
// Create a mail session
System.out.println("SMTPHostname ====>"+smtpHost);
java.util.Properties props = new java.util.Properties();
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port", ""+smtpPort);
Session session = Session.getDefaultInstance(props, null);
// Construct the message
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
msg.setSubject(subject);
msg.setText(content);
// Send the message
Transport.send(msg);
}
public static void main(String[] args) throws Exception {
// Send a
test message
send("mail.vsnl.co.in", 25,"portal.teamibm@vsnl.co.in","vinod.shirke@tcs.com","Test Mail", "How about at this mail?");
}
}
Exception in
thread "main" com.sun.mail.smtp.SMTPSendFailedException: 454 5.7.3
Client does not have permission to submit mail to this server.
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1
333)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:906)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:535)
at javax.mail.Transport.send0(Transport.java:151)
at javax.mail.Transport.send(Transport.java:80)
at SendApp.send(SendApp.java:24)
at SendApp.main(SendApp.java:29)
Kindly provide some solution
Regards