Professional Web Applications Themes

dummy smtp server in C or Perl - UNIX Programming

Hi all, I'm tasked with writing a 'dummy' smtp server for our Linux mail server. The idea is that when we temporarily kill the server (Exim) for whatever reason, we start the 'dummy' server, which accepts connections and always reports "421 Too Busy". This way, we don't look like we're down to our internal email clients (or the Internet). While easier, I can't use inetd to help me out. My solution needs to be a 'drop in' for the Exim daemon. I can write this to work for a single connection at a time, BUT to be accurate, it should ...

  1. #1

    Default dummy smtp server in C or Perl

    Hi all,
    I'm tasked with writing a 'dummy' smtp server for our Linux mail server.
    The idea is that when we temporarily kill the server (Exim) for whatever
    reason, we start the 'dummy' server, which accepts connections and always
    reports "421 Too Busy". This way, we don't look like we're down to our
    internal email clients (or the Internet).

    While easier, I can't use inetd to help me out. My solution needs to be a
    'drop in' for the Exim daemon.

    I can write this to work for a single connection at a time, BUT to be
    accurate, it should really accept multiple connections simultaneously, if
    necessary, via forking, or polling, or whatever....

    I've been Googling and can't find anything close. Any tips are welcome.
    --
    Thanks,
    Mike


    Mike Guest

  2. #2

    Default Re: dummy smtp server in C or Perl

    Mike Scott <com> wrote: 

    Are you sure this will do what you want? Other SMTP servers will likely queue
    the mail to try again, but MTAs that try to send mail may harass the user
    about the "unavailable" server. You'd want to test this out with your
    supported mail clients...

    A better solution is likely to run two mailservers, both exim (or whatever),
    with one just forwarding all mail to the other. Both get listed as MX
    servers, with the main one as a higher priority. When doing maintenance, just
    take the main server offline. Clients who can't connect will just use the
    other server. When it's back online, the other server will deliver the mail
    to the primary and life is good.

    They can be on the same machine if you use 2 network addresses, but using a
    seperate machine as a backup MX lets you do real maintenance on the first
    which includes actual server (as opposed to service) downtime.

    What kind of crazy maintenance procedure do you have that you need to down the
    process for any period of time, but don't mind keeping the machine online and
    functioning?
     

    If you absolutely must do this crazy thing, any unix network programming book
    should have an example of a server that handles multiple connections. If
    you're using Perl, the camel book has an example in the Sockets section of the
    IPC chapter which you can start with.
    --
    Mark Rafn net <http://www.dagon.net/>
    Mark Guest

  3. #3

    Default Re: dummy smtp server in C or Perl

    In article <a7wWb.476182$ts4.223853pd7tw3no>,
    "Mike Scott" <com> wrote:
     

    When a connection is accepted, fork a child process or spawn a thread,
    and have it do its "single connection at a time" stuff. The parent
    should close its copy of the socket descriptor and loop back to accept().

    --
    Barry Margolin, mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    Barry Guest

  4. #4

    Default Re: dummy smtp server in C or Perl

    Hi Mark,

    I think somebody likes the word 'crazy'. ;-{).
    The reason I disable our MTA is in the event of a virus scare (we just had
    one). Unfortunately, many of my 150 users call to complain that their
    Outlook client is reporting "ERROR - Unable to connect to the server. (blah
    blah...)". Obviously, with the MTA offline, I can't just email everybody to
    inform them (sometimes the virus threat is such that I must switch off Exim
    immediately).
    No, I haven't tested how Outlook responds to a 421. My hope was that it
    would be transparent, and just try to send Outbox items at the next
    interval. Perhaps not...
    Your idea about a second mail server is overkill for what I'm trying to
    accomplish, but it has spawned an idea. Perhaps a second Exim config that
    receives messages, but defers delivery until it's safe to do so.
    Hmmmmm...........

    Thanks for the reply. -Mike

    "Mark Rafn" <net> wrote in message
    news:c0ea40$vsi$39.155.144... 
    >
    > Are you sure this will do what you want? Other SMTP servers will likely[/ref]
    queue 
    whatever), 
    just 
    mail 

    the 
    and 
    >
    > If you absolutely must do this crazy thing, any unix network programming[/ref]
    book 
    the 


    Mike Guest

Similar Threads

  1. Replies: 1
    Last Post: September 27th, 09:18 PM
  2. Replies: 7
    Last Post: June 10th, 02:11 PM
  3. SMTP Server
    By hemachander in forum ASP Components
    Replies: 0
    Last Post: September 12th, 10:22 AM
  4. Using SMTP through a proxy server
    By news@roaima.freeserve.co.uk in forum PERL Miscellaneous
    Replies: 0
    Last Post: July 22nd, 08:28 AM
  5. How do I set up Windows XP's SMTP server?
    By Pierre Orantes in forum Windows Networking
    Replies: 0
    Last Post: July 11th, 05:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139