2017-08-01 10 views
0

私はメールを送信するためのjavax.mailパッケージ を使用していますが、デバッグモードのアプリケーションではうまく動作し、すべてのメールを自分のアカウントに送りますが、フォームアプリケーションを送信するメールの停止。下記のよう コードは次のとおりです。Javax.mailパッケージがリリースモードで動作しませんでしたapk

Properties props = new Properties(); 
    props.put("mail.smtp.user", "[email protected]"); 
    props.put("mail.smtp.host", "smtp.gmail.com"); 
    props.put("mail.smtp.port", "465"); 
    props.put("mail.smtp.starttls.enable", "true"); 
    props.put("mail.smtp.debug", "true"); 
    props.put("mail.smtp.auth", "true"); 
    props.put("mail.smtp.socketFactory.port", "465"); 
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); 
    props.put("mail.smtp.socketFactory.fallback", "false"); 

    //Creating a new session 

    session = Session.getDefaultInstance(props, new javax.mail.Authenticator() { 
     //Authenticating the password 
     protected PasswordAuthentication getPasswordAuthentication() { 
      return new PasswordAuthentication("[email protected]", "[email protected]"); 
     } 
    }); 
    try { 
     //Creating MimeMessage object 
     MimeMessage mm = new MimeMessage(session); 

     //Setting sender address 
     mm.setFrom(new InternetAddress("[email protected]")); 
     //Adding receiver 
     mm.addRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]")); 
     //Adding subject 
     mm.setSubject(subject); 
     //Adding message 
     mm.setText(message); 

     //Sending email 
     Transport.send(mm); 

    } catch (MessagingException e) { 
     e.printStackTrace(); 
    } 

答えて

0

一般的にこの問題は、あなたのプロジェクトにProGuardのを追加した場合、それはこのような機能の一部を停止されます、なぜならProGuardので起こります。

私はproguard-rules.proファイルにjavaxというパッケージを追加しました。

-keepクラスのjavax ** {*;}。

これは、ProGuardの中のすべてのjavax法の許可を追加します。

関連する問題