Sending an Email Using Java

Posted by user217029 on Stack Overflow See other posts from Stack Overflow or by user217029
Published on 2009-11-23T17:31:29Z Indexed on 2010/04/08 20:03 UTC
Read the original article Hit count: 253

Filed under:
|
|
 try{
        Properties props = new Properties();
        props.put("mail.smtp.host", "ipc-smtp.bits-pilani.ac.in");
        Session sess = Session.getInstance(props, null);
        sess.setDebug(true);
        Message msg = new MimeMessage(sess);
        InternetAddress addressFrom = new InternetAddress("[email protected]");
        msg.setFrom(addressFrom);
        msg.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
        msg.addHeader("MyHeaderName", "myHeaderValue");
        msg.setSubject("Test");
        msg.setContent("Yippe", "text/plain");
        Transport.send(msg);
        }catch(Exception exp){
           exp.printStackTrace();
        }

The error is javax.mail.MessagingException: 554 The mail was blocked due to zen-spamhaus RBL action

This is my college's smtp server.

© Stack Overflow or respective owner

Related posts about email

Related posts about java