I would like to implement an error reporting mechanism into my application: If an error happens the user should be able to directly send me this error message.

I thought of doing this with JavaMail. My question is now: to send an email I have to authenticate on an SMTP-Server. Is it save to write the password into the source code? Or what is the proper way of implementing an error reporting function?

have your application run on your server, and check the logs on a regular basis.
I don't really understand what it is you're trying to do: an application that runs at the clients system and the logfiles go to you?

have your application run on your server, and check the logs on a regular basis.
I don't really understand what it is you're trying to do: an application that runs at the clients system and the logfiles go to you?

Oh sorry, I probably should have mentioned that the application doesn't run on a Server. It is a normal standalone application that could run on any computer (with no connection to any Server).

impossible.
it still needs to have a connection with somewhat of your system, at the very least the internet, on which you somewhere have space or a db to store the loggings.

let's say they don't have internet access, but they're trying to login and that's supposed to be entered in the log-files, it can't connect to the log-file and that might cause an exception to be thrown. chicken and egg rules, doesn't it? :)

impossible.
it still needs to have a connection with somewhat of your system, at the very least the internet, on which you somewhere have space or a db to store the loggings.

let's say they don't have internet access, but they're trying to login and that's supposed to be entered in the log-files, it can't connect to the log-file and that might cause an exception to be thrown. chicken and egg rules, doesn't it? :)

I think you do not understand me correctly. This kind of feature is integrated in several applications and it should give therefore a solution.

Use Case: If an error occures a Window appears with the error message (as in every application). The window contains a button e.g. "Report Error to developer". If the user clicks on it, it sends me a email or similar with the error message. If there is no internet connection it notifies the user that it is not possible to transmit.

Shouldn't be that hard...just this password thing to MY SMTP-Server to transmit the message is somehow unsecure.

well .. there are tons of examples out there that provide you with the code to send an e-mail using a gmail address.

you can always create a dummy gmail address and use code like that to send an error report by mail.

since that e-mail address itself is not important, you could hard-code the password I guess, but off course that's open to debate. :)

yes, I know how to send an email with JavaMail :-) I just hoped that there is a nicer solution than with this hard-coded password.

well, I wasn't just talking about JavaMail, there are other ways to do it, but you should understand that Microsoft (the Windows error you refer to) has it's own servers and there on installed, mail servers.

if an error occurs, your Windows OS will contact one of their services on their servers, and they only have to pass the contents of the message, since everything else is done on their own servers.

unless you are setting up your own server (doesn't have to be a mailserver, just a local service to handle incoming error messages) and you still want to have the messages mailed to you, I don't really see another option.

but be aware of the risks: you are still the 'owner' of said e-mail account. all someone has to do, is to decompile your code to get your hardcoded login and password, and they can send lots and lots of spam, for which you would be responsible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.