0

HI I have no issue using log4net in winform app to send error email to myself when i test the app at my own workstation. However, when i test the same code at my company and my client pc, it just failed sending out error email. I think for company it has been blocked by the proxy which i can understand. However, for my client whom is using window7 for personal use also failed to send out email and this really surprised me.
Kindly advice

This is the code i used.

 <log4net>   
<!-- tested success on hotmail with port 587 -->
<appender name="smtpAppender" type="log4net.Appender.SmtpAppender">
  <to value="xxx@hotmail.com" />
  <from value="xxx@hotmail.com" />
  <subject value="Error Report" />
  <authentication value="basic" />
  <smtpHost value="smtp.live.com" />
  <username value="xxx@hotmail.com" />
  <password value="xxx" />
  <port value="587" />
  <bufferSize value="512" />
  <lossy value="true" />
  <evaluator type="log4net.Core.LevelEvaluator">
    <threshold value="ERROR" />
  </evaluator>
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" />
  </layout>
</appender>
<root>
  <level value="ERROR" />
  <appender-ref ref="smtpAppender" />
</root>

VeecoTech
  • 2,073
  • 8
  • 37
  • 49
  • "for my client whom is using window7 for personal use" - is that on the same (probably restricted) client network, or somewhere else? Can you ask them what SMTP server they use for their email, either on-site or wherever they are, and configure that? And if that doesn't work, try changing the 'from' address to something that definitely works with their SMTP server too. – Rup Jun 24 '11 at 13:59
  • @Rup: my client's pc is just the home pc with no restriction. I think they do not have SMTP setup on their PC. how do i setup one for them? Currently i put the FROM email exactly the same as the TO. Is this the root cause? Can i leave the FROM Empty? – VeecoTech Jun 24 '11 at 14:22
  • They'll almost certainly have an SMTP server provided by the ISP - the one they've configured into their email program. They should use that. The issue with the from address is that the ISP SMTP server might not allow sending from arbitrary addresses, e.g. if they were with AOL it might reject all email not from or to an AOL address (hypothetical - I don't know if that happens). No, you shouldn't leave it blank. – Rup Jun 24 '11 at 14:33
  • @Rup: oppss, my program is deployed to many PC. How can i specify all the SMTP email from each clients for the FROM. – VeecoTech Jun 24 '11 at 14:57
  • @Rup: My app required to deploy to many client pc. In this case, how do i specify their personal SMTP onto the code? If i do so, then other PC will be having problem to send email. Please advice – VeecoTech Jun 25 '11 at 23:52
  • I don't think you can - you'd have to ask the user as part of the install process. But were you really planning to hand out login credentials for a hotmail account in the web.config for all of your separate users to install? The account would almost certainly get cancelled quickly. But if this is for error reporting back to you, wouldn't it be better to host a web service on one of your servers and have all the applications upload to that web service, rather than have everyone email you? Or generate a crash log and prompt them to email it in, or something along those lines. – Rup Jun 26 '11 at 16:29
  • @Rup: ` to host a web service on one of your servers and have all the applications upload to that web service, rather than have everyone email you?` .. This sound good and something new to me, could you send me a link of tutorial for this? I am very interest in it. – VeecoTech Jul 04 '11 at 06:46

1 Answers1

0

your application may not be running with enough previlleges @ the client's machine ?

Illuminati
  • 4,539
  • 2
  • 35
  • 55
  • May i know how to view the privileges or grant the pc with full privileges on this? – VeecoTech Jun 24 '11 at 08:49
  • try running it as a administrator and see if that makes a difference – Illuminati Jun 24 '11 at 10:12
  • @Bumble Bee: yes i sign in as administrator but it is still the same – VeecoTech Jun 24 '11 at 13:51
  • Singning in as administrator may not be enough. Try running the application with administrator privileges. – Illuminati Jun 25 '11 at 08:42
  • @Bumble Bee: But it is not a good idea to ask my client to always right click and run as admin. waht do u think? – VeecoTech Jun 25 '11 at 23:40
  • it makes me so hard to test. I have tested my code on 2 personal home computer. THe email works just fine. But i still do not able to reproduce why my client PC failed to generated the error email to me. – VeecoTech Jun 25 '11 at 23:47
  • running it as an admin was just suggested to figure out if that is due to a permission issue. If that is working fine in that mode, you should be able to heighten the level of security for you app using code access security principles. http://msdn.microsoft.com/en-us/library/aa720521(v=vs.71).aspx – Illuminati Jun 26 '11 at 04:48
  • Bee: I have tried running the app in my company using "Run as administrator", however i still do not get the error email to my inbox. Running the same code at my home and my friend home work just fine.. – VeecoTech Jul 04 '11 at 06:41