Sent letters from the MIDlet or How I remotely caught error
Many people probably came up with the idea that sending out application letters to the e-mail would be very helpful. For example as feedback about the program or registration, but who knows what else. And me in the development of the program wanted to receive messages with errors in the program, as being a indie developer, have handy a dozen of the most common phones, and conduct large-scale testing on a wide range of devices, especially the new, not so easy. Therefore, the mechanism of notification errors would be very helpful, at least at the stage of beta testing. Digging in the net I found some libraries for working with email, including mobilab'. But no matter how much tried, I could not send email, although the demo worked. The clock was ticking.
As the proverb says,
I found this site the source e-mail client, and at least he earned. But unfortunately found some problems with encoding special characters and Cyrillic. Had to whip to add your encoder lines. All issued to the library, wrote a class for working with her and added to the application. At first it was a separate paragraph from which users could in which case send message, which came to my mail.
Later came to the conclusion that reliability will be to automate this case, advance notice to users about collecting information about errors.
As a result code sent was:
the
And the letter I have looks roughly like this
And the actual handler-otpravit
the
Well, the source code libraries goo.gl/oVv8e
Article based on information from habrahabr.ru
As the proverb says,
this DIY
I found this site the source e-mail client, and at least he earned. But unfortunately found some problems with encoding special characters and Cyrillic. Had to whip to add your encoder lines. All issued to the library, wrote a class for working with her and added to the application. At first it was a separate paragraph from which users could in which case send message, which came to my mail.
Later came to the conclusion that reliability will be to automate this case, advance notice to users about collecting information about errors.
As a result code sent was:
the
} 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();
}
And the letter I have looks roughly like this
And the actual handler-otpravit
the
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;
}
}
Well, the source code libraries goo.gl/oVv8e
Комментарии
Отправить комментарий