Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

API JavaMail exception

843834Sep 4 2008 — edited Sep 15 2008
Hi there,

I got a strange problem with the API JavaMail where I cannot send email throw my smtp server.
Here I give you my java class and the debug trace associated with :
public class SendMail {
    /*------------------------------------------------
     * 		ATTRIBUTES
    --------------------------------------------------*/

    private String configFile;
    private ProfileReader wini;
    private InputStream inStream = null;
    private String host;
    private String userName;
    private String userPassword;
    private Address fromAddr;
    private Address replyAddr;
    private String userAddr;
    private String subject;
    private String content;
   
    /*------------------------------------------------
     * 		CONSTRUCTORS
    --------------------------------------------------*/

    public SendMail() throws MessagingException {

        this.configFile = "." + File.separator + "config.ini";
        this.wini = new ProfileReader(this.configFile);
        try {
            this.inStream = new FileInputStream(this.configFile);
            this.wini.loadIniConf(this.inStream);
        } catch (FileNotFoundException e01) {
            e01.printStackTrace();
            System.out.println("E01 : " + e01.getMessage());
        } catch (Exception e02) {
            e02.printStackTrace();
            System.out.println("E02 : " + e02.getMessage());
        }

        this.host = this.wini.getProperty("mail", "smtpServer");
        this.userName = this.wini.getProperty("mail", "userName");
        this.userPassword = this.wini.getProperty("mail", "userPassword");
        this.userAddr = this.wini.getProperty("mail", "userAddress");

        this.fromAddr = new InternetAddress(this.userAddr);
        Address[] toAddr = {new InternetAddress(this.userAddr)};

        this.subject = "Alert";
        this.content = "First email throw JavaMail";

        Properties props = new Properties();
        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.host", this.host);

        Session session = Session.getInstance(props);
        session.setDebug(true);

        MimeMessage msg = new MimeMessage(session);
        msg.setFrom(this.fromAddr);
        msg.setRecipients(Message.RecipientType.TO, toAddr);
        msg.setSubject(this.subject);
        msg.setContent(this.content, "text/plain");
      
        Transport transport = session.getTransport("smtp");
        try {
            transport.connect(this.userName, this.userPassword);
            transport.sendMessage(msg, msg.getAllRecipients());
        } finally {
            transport.close();
        }
    }
}
and the trace :
DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.server.com", port 25, isSSL false
220 FRVELSBHS05.ad2.ad.server.com   Thu, 4 Sep 2008 23:49:40 +0200 
DEBUG SMTP: connected to host "smtp.server.com", port: 25

EHLO FRORVN0F04253
250-FRVELSBHS05.ad2.ad.server.com Hello [155.132.93.216]
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-TLS
250-STARTTLS
250-X-EXPS GSSAPI NTLM
250-AUTH GSSAPI NTLM
250-X-LINK2STATE
250-XEXCH50
250 OK
DEBUG SMTP: Found extension "TURN", arg ""
DEBUG SMTP: Found extension "SIZE", arg ""
DEBUG SMTP: Found extension "ETRN", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "8bitmime", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "VRFY", arg ""
DEBUG SMTP: Found extension "TLS", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "X-EXPS", arg "GSSAPI NTLM"
DEBUG SMTP: Found extension "AUTH", arg "GSSAPI NTLM"
DEBUG SMTP: Found extension "X-LINK2STATE", arg ""
DEBUG SMTP: Found extension "XEXCH50", arg ""
DEBUG SMTP: Found extension "OK", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: use8bit false
MAIL FROM:<Bap@server.com>
454 5.7.3 Client does not have permission to submit mail to this server.
DEBUG SMTP: got response code 454, with response: 454 5.7.3 Client does not have permission to submit mail to this server.

RSET
DEBUG SMTP: EOF: [EOF]
javax.mail.MessagingException: [EOF]
        at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1481)
        at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1512)
        at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1054)
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:634)
        at snec.models.audit.auditModel.treatment.SendMail.<init>(SendMail.java:104)
        at snec.Main.main(Main.java:31)
I can send email via Outlook Exchange with this account so.... i got a problem.
Does anyone can help me, please ?

Regards,
Bap
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 13 2008
Added on Sep 4 2008
12 comments
3,550 views