Find the answer to your Linux question:
Results 1 to 9 of 9
Hi, I`d like to know how to go about writing an email notification program. I know that there are many such programs available but what I would like to do ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    8

    How to write email notification program

    Hi,

    I`d like to know how to go about writing an email notification program.

    I know that there are many such programs available but what I would like to do is this: monitor for incoming mails, upon receiving an email from a specific email address, read the content of email (which is one word) and depening on the email content, execute a command.

    Or, if anyone can tell me about an existing email notification program with this feature, then thats also fine.

    I am using Ubuntu and the Mail Transfer Agent,Mail Delivery Agent and Mail User Agent will be whatever Ubuntu has. I`d just like to know the steps that i have to carry out to do the above.

    Thanks

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Hello,

    if you want to write this program for a specific mail account, it should be not too difficult. But it depends on which protocol the mail server speaks.

    The two most common are POP3 and IMAP. Both are very simple clear-text protocols, the former being the easiest, the latter having more features.

    You can read about them in great detail
    here http://www.ietf.org/rfc/rfc1939.txt
    and
    here http://www.ietf.org/rfc/rfc2060.txt

    They are so simple that you can actually use Telnet to connect to your mail server and "talk" to him in order to get a feeling for it.

    In the next step, you write a small application that sends the necessary commands over sockets on a regular basis and notifies the user on demand.
    Debian GNU/Linux -- You know you want it.

  3. #3
    Just Joined!
    Join Date
    Oct 2008
    Posts
    8
    Hi,

    Thanks your for reply.

    "In the next step, you write a small application that sends the necessary commands over sockets on a regular basis and notifies the user on demand"

    Could you please just give a few more details on what to do in this part with some of the common commands needed? this will help me get started in the right direction.

    Thanks

  4. #4
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Hello,

    Could you please just give a few more details on what to do in this part with some of the common commands needed? this will help me get started in the right direction.
    Well, this depends on the programming language you will use, of course.
    Is there any language you are familiar with already? Preferable C or C++.
    Debian GNU/Linux -- You know you want it.

  5. #5
    Just Joined!
    Join Date
    Oct 2008
    Posts
    8
    Hi,

    Yes...fortunately C/C++ is what I originally intended to use, and am quite familar with it.

    I`ve already managed to talk with the mail server using telnet (thanks!) . I understood a lot of things

    Now just some commands in C/C++ is what I need to start implementing. i`m using Linux (Ubuntu) by the way.

    Thanks so much

  6. #6
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Hello,

    this is good, because it is mostly straightforward in C/C++.
    You will want to use "sockets" (google for one of the plenty excellent tutorials about them).
    Berkeley sockets - Wikipedia, the free encyclopedia

    Basically, one establishes a TCP connection to the mail server over sockets and then streams to it the very same text you just typed in on your Telnet session.

    Security considerations aside (cleartext over unsecured lines), this is about all.
    Debian GNU/Linux -- You know you want it.

  7. #7
    Just Joined!
    Join Date
    Oct 2008
    Posts
    8
    Thanks a lot!! I will try it out

  8. #8
    Just Joined!
    Join Date
    Oct 2008
    Posts
    8
    Hi

    I`ve managed to read email from a POP3 server but i was wondering if you could help me with another issue.

    I currently have a char pointer that points to the beginning of the message and when I print it, all sorts of info gets printed.

    Is there a way in which I can retrieve specifc parts of the email? for e.g sender email address or actual mail content? I can do this by printing only a certain range of elements pointed the pointer but its not very neat as it involves trial and error and so doesnt work with varying-length messages as i have no way of pre-empting the length of an email message.

    Would you have any idea about this?

    Thanks

  9. #9
    Just Joined!
    Join Date
    Oct 2008
    Posts
    8
    Hi...i guess i`ve answered my questions...rfc5322 is what I was looking for.

Posting Permissions

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