tags:

views:

1255

answers:

9

I'd like my program to be able to email me error reports. How can I do this without hard-coding a username/password/SMTP server/etc. into the code? (Doing so would allow users to decompile the program and take over this email account.)

I've been told you could do some stuff with telneting to port 25, but I'm very fuzzy on the details. Most of the code snippets on Google assume you have a preexisting account, which doesn't work in this situation.

I am using .NET v3.5 (C# in particular), but I would imagine the ideas are similar enough in most languages. As long as you realize I'm doing this for an offline app, and don't supply me with PHP code or something, we should be fine.

+1  A: 

If the program has to email you directly, it has to get that information somehow, so a determined attacker could gain that information as well.

Have you considered hosting a simple http form or web service somewhere, so that you could post the information you need there from the application (no authentication required), and either save it to manually look at later, or send the email from that server?

Chris Marasti-Georg
+7  A: 

As long as your account is on gmail.com, set up gmail-smtp-in.l.google.com as the outgoing SMTP-server in your program. You do not need to provide a password to send email to gmail-accounts when using that server.

Espo
What if you're To: address is not a gmail address? What are some good alternatives for that situation?
greg7gkb
+5  A: 

I would create a webservice to connect to. This webservice should send the email based on the data your program provide. All sensitive access-data is kept on the webservice side, so it's safer.

Biri
A: 

I think the best plan would be to submit the error information to some service (in the simple case, a web form) running under your control, which could then send an email (or log it in some other appropriate way).

If sending the email is assumed to be of benefit to the end user, another option would be to have the user enter their own SMTP server (and username / password if required) - On Unix systems, you can possibly just use sendmail and rely on the user to have it configured correctly. I used to work on a system which used this approach to send the user reports of the system's scheduled tasks, and that worked quite well.

Matt Sheppard
A: 
MailMessage msg = new MailMessage("[email protected]", "[email protected]");
msg.Subject = "Check it out!";
msg.Body = "Visit stackoverflow.com!";
SmtpClient client = new SmtpClient("some.smtp.server", 25);
client.Send(msg);
aku
A: 

well, if your mail admin let you, you can use a great command line smtp mailer called blat (blat.net) to do it. However, you do have to put in the 'from' address but don't have to use an id or a password.

It's a great little program.

Keng
A: 

Wait, does this site not have reply buttons? :-|. OK, one at a time then:

@Keng: that doesn't look like it would work; as far as I can tell blat is just a utility for sending mail through preexisting servers/accounts.

@aku: So, where do I get this magical "some.smtp.server"?

@Matt, @Biri: I agree a web service would be optimal; however, I'm kind of trying to host this program off of a free GooglePages account, which obviously doesn't allow such things. It would also be nice if my code was reusable by other hobbyists who probably don't have access to a setup.

@Matt: Regarding having the user enter their stuff, that seems like an unnecessary burden on the user, and would discourage sending error reports. And this is a Windows program, so no sendmail, sadly.

@Espo: that looks just about perfect! I did not know that would work! I guess it's a bit situational, but it works for my program!

@Chris: I'm not quite sure how to interpret your first sentence. I'm not trying to prevent others from sending email (or, say, spoofing error reports); I'm trying to prevent them from taking over the account and locking me out of it.

The idea of a webform makes some sense, but seems like a bit of a hack, and runs into the same problems as a webservice.


All in all, thanks everyone! That was an amazingly quick series of responses, almost all of which were quite helpful and a few of which even worked inside the limitations I failed to outline in the original question!

Domenic
You're not supposed to reply in a separate answer I think, just post comments on the different answers :)
CFP
Note the post time; this was when the site started, before commenting was even a feature.
Domenic
A: 

@Domenic, I simply meant that if you wanted to use SMTP credentials to send an email from the client application, running on a client's computer, there would not really be a way to keep a truly determined person from getting those credentials.

Chris Marasti-Georg
A: 

@http://stackoverflow.com/questions/29988/how-to-send-email-from-a-program-without-using-a-preexisting-account#30007">Aku

MailMessage msg = new MailMessage("[email protected]", "[email protected]");
msg.Subject = "Check it out!";
msg.Body = "Visit stackoverflow.com!";
SmtpClient client = new SmtpClient("some.smtp.server", 25);
client.Send(msg);

that's an awesome way to do a c# mail w/o a password! Just what we needed today. Thanks!!!!

Keng