Results 1 to 5 of 5

Thread: Anyone Know Of An Email To HTML Script / Program

  1. #1
    You do realize by 'gay' I mean a man who has sex with other men?
    Join Date
    Oct 2003
    Location
    New Orleans, Louisiana.
    Posts
    21,635

    Anyone Know Of An Email To HTML Script / Program

    I want to be able to send an email to a specific address then based on a template, whatever text is sent in the email message is read by the script then a page on the server is generated from it.

    Anyone know of such a script, preferably PHP based?

    Regards,

    Lee


  2. #2
    temptationhouse
    Guest
    i guess it wont exist but if you have basic php skills it should be easy to write.
    with your php script:

    ... use pop or imap functions to check a mailbox you define
    ... on new mail get the message body, parse it accordingly
    ... create new page.

    run this script from cron say every 10 minutes and you're done.


  3. #3
    No no i'm really handsome, all the lesbians love me.
    Join Date
    Dec 2007
    Posts
    103
    To actually put whatever is in the email into the .html, you could
    just put one or two lines in your .forward or .procmailrc file and then
    send to yourftpusername@yourserver.com. That would have security
    issues, though, so instead we'll pipe it through a program which
    checks the input. In .procmailrc:

    Code:
    :0 H b:
    * Subject: update page
    | /home/user/bin/email2html.pl

    In /home/user/bin/email2html.pl:
    Code:
    #!/usr/bin/perl
    
    my $htmlpage = '../domain/public_html/blah.html';
    open HTML ">$htmlpage" or die "could not open '$htmlpage': $!"
    while (my $line = <STDIN>) {
        # Do whatever checks on the input.  Allow ONLY legal characters, disallow 
        # anything else.
        print HTML $line;
    }
    close HTML;
    The above code is off the top of my head, untested, but it's so simple
    a task that it shouldn't have any major errors. We're just reading from
    standard input and writing to a file.


  4. #4
    No no i'm really handsome, all the lesbians love me.
    Join Date
    Dec 2007
    Posts
    103
    This post messed up, deleted.


  5. #5
    No no i'm really handsome, all the lesbians love me.
    Join Date
    Dec 2007
    Posts
    103
    I just re-read your orginal messge where you said there would be a
    template. In that case the details will vary depending on what types of
    information you want to send and whether to want to replace the existing
    info or if you want to add to it, but it'll look a lot like this:

    HTML Code:
    #!/usr/bin/perl
    
    my $htmlpage = '../domain/public_html/blah.html';
    my $template = '../domain/public_html/blah.tmpl';
    
    open TMPL, $template or die "Could not open '$template': $1";
    my @lines = <TMPL>;
    close TMPL;
    
    my $tmplhtml = join("\n", @lines);
    
    
    while (my $line =<STDIN> ) {
        $line =~ s/[^a-zA-Z0-9\n\s\:]//g;  # allow just letters, numbers, spaces, and colons
        if ($line =~ m/([^:]*): (.*)/) {
            $find = $1; $replace = $2;
            $tmplhtml = s/$find/$replace/g;
        }
    }
    
    
    open HTML ">$htmlpage" or die "could not open '$htmlpage': $!"
    print HTML $tmplhtml;
    close HTML;


Posting Permissions

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