Programatically POP mail from an ASP.NET MVC app

Discussion in 'Site Programming, Development and Design' started by Sean, Jun 19, 2010.

  1. Hi there

    I am working on a new ASP.NET MVC app.

    One action/page in particular automatically reads emails from my Winhost email address, using POP port 110 @ mail.[myWinhostdomain].com.

    When the ASP.NET app runs on my PC here at home, it can read emails fine from my Winhost email address.

    However when I deploy the ASP.NET to my Winhost site,
    the C# code cannot log in to the POP server. This is even with the exact same mail settings!

    I've also tried setting POP server to localhost.

    Is there any other port or POP server I should be using ?

    Many thanks,

    Sean
     
    Last edited by a moderator: Oct 14, 2015
  2. Security blocking attempt to open socket

    I had another go at POPing mail from within my web site.

    I swapped C#Mail and instead use OpenPop library.

    When OpenPOP tries to connect to my win host mail server, this exception occurs:

    Code:
    Security Exception
    
    Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 
    
    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Net.SocketPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
    
    Source Error: 
    
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    
    Stack Trace: 
    
    
    [SecurityException: Request for the permission of type 'System.Net.SocketPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
       System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port) +748
       OpenPOP.POP3.POPClient.Connect(String strHost, Int32 intPort, Boolean useSsl) +209
    
    I've had a look around the IIS7 Manager - and can't see any settings for POP mail.
    My application seems to have Full Permissions.

    Wonder is there any way to POP mail from within a Winhost web site ?
     
    Last edited by a moderator: Oct 14, 2015
  3. Ray

    Ray

    Last edited by a moderator: Oct 14, 2015
  4. I've tried that - but still does not work.

    A workaround I have, is to use a Windows Service hosted on my own PC, that does the POPing and processes the emails.
     
  5. actually I just tried it again , with Port=110 and it works !

    cheers for that

    :)
     
  6. Ray

    Ray

    Odd what was the default port OpenPOP was using?
     
  7. I had OpenPop set to port 143

    I think the default is 110.

    110 is what worked for me.
     
  8. Yes, default/standard is 110 for POP. Glad it's working for you.
     

Share This Page