一般的な知恵が言うように
うまくやりたいですか、自分でやります
このサイトでメールクライアントのソースを見つけましたが、少なくとも動作しました。 しかし、残念ながら、特殊文字とキリル文字のエンコードに関する問題を発見しました。 すぐに独自の文字列エンコーダを追加する必要がありました。 ライブラリ内のすべてを設計し、それを操作するためのクラスを作成し、アプリケーションに追加しました。 最初は、ユーザーが自分のメールに届いたメッセージを送信できる別のアイテムでした。
後で、エラーに関する情報の収集についてユーザーに以前に警告していたので、このビジネスを自動化する方が信頼性が高いという結論に達しました。
その結果、最終的な送信コードは次のようになりました。
} catch (Exception ex ){ sendMail("main class","some method" , ex); } public void sendMail(string classname, String methodname, Exception e) { SendMail mail=new SendMail(); mail.setText(classname+":"+methodname+":"+ e.toString()); mail.start(); }
そして私の手紙はこんな感じ
そして実際には送信者ハンドラ
import Mail.Connection; import Mail.Decoder; import Mail.Message; import Mail.SmtpClient; public class SendMail extends Thread { String host = "smtp.mail.ru"; int port=25; String adressfrom = "bugreport@mail.ru"; String pass = "123456"; String adressto = "s.komlach@gmail.com"; String subject = "Bugreport"; String text = ""; public void run() { try { String string = Decoder.encode(text, false); SmtpClient smtpclient = new SmtpClient(new Connection()); smtpclient.open(host, port, adressfrom, pass); Message message = new Message(adressfrom, adressto, Decoder.encode(subject), true)); message.addHeaderLine("X-mailer: 1.0"); message.addHeaderLine("Content-Type: text/plain; charset=UTF-8"); message.addHeaderLine("Content-Transfer-Encoding: quoted-printable"); message.addBodyLine(string.concat("\r\n")); smtpclient.sendMessage(message); smtpclient.close(); } catch (Exception exception) { } } public void setText(String text) { this.text = text; } }
さて、 goo.gl / oVv8eライブラリソース