Addon Idea: Submit news with posting a e-mail

Post your requests for addons here, and discuss any addons in development here, as well.
Once an addon has completed development, it will be released in the "Addon Release" forum.

Moderator: Spunkmeyer

Postby kriko » Thu Jul 24, 2003 1:58 am

LMAO, this topic is more than a YEAR OLD :shock:
Post before you was made on 30th June 2002 :p

seems this is not going to be done as it was planned :p a year ago :p
Kristjan aka. kriko
now a wireless expert
User avatar
kriko
 
Posts: 3328
Joined: Sat Feb 24, 2007 8:13 pm

Postby Yoshi » Tue Feb 08, 2005 3:13 pm

2005 & I still think it's a good idea :)
I would love to try this but it would take another three years for me to learn how. :idea: Perl for dummies anyone
Yoshi
 
Posts: 40
Joined: Thu May 01, 2003 11:18 am

Postby cerberos76_ » Tue Feb 08, 2005 4:16 pm

The idea is good. Still you need to find time to do everything... and sometime you cannot do everything you would like to do (at least not for free). So that idea has gone out of my pressing to-do list.

But don't think that perl is so difficult you cannot write such an addon in a short time (I would say less than 2 months if you wish to learn it seriously).
Coranto addons:
* GuestPost, one click guestposting
* MoveIt!, Advanced Backup and site transfer
* PartialRebuild, CPU-friendly enhancement of FullBuild
* URLColumn, URLs for multiple Categories/Profiles
* Tickit!, Javascript News Tickers/Faders for Coranto!
* AddonEnabler, enables or disables single, multiple or all addons in one go
* SubmitMultiple, post consecutive news in an automatic loop!
* RSSAdvanced, RelatedNews ....

Get them at: http://coranto.gweilo.org/addons/
cerberos76_
 
Posts: 1339
Joined: Sun Mar 10, 2002 1:21 am

Postby Yoshi » Wed Feb 09, 2005 11:23 am

I am indeed learning,

I have already written the part to check the pop mail account.
And I managed that in one night.

Now I just need to figure out how to intergrate that with coranto.

My idea is to parse the email by means of tags

[subject]
test title
[/subject]

[Text]
blah blah blah
[/Text]


that kind of thing,

If you have any time to spare and you have any pointers, all help in this would be very much appreciated.

as an aside cerberos76 could you pm me with a cost of what you would charge (given the time) to build this addon?
Yoshi
 
Posts: 40
Joined: Thu May 01, 2003 11:18 am

Postby cerberos76_ » Wed Feb 09, 2005 1:42 pm

yes, your idea is correct.
The exact syntax can vary but you are on the right track.

To integrate with the coranto there are different methods according to how you wish to achieve the posting. The method that would be most convenient is a programmed 'ghost posting' and rebuild which is controlled by a small perl daemon at regular intervals. So you would have to build these pieces:
- the mail checking code (similar to a pop3 retrieval program)
- the 'ghost posting' code (not too dissimilar to what done in Guestpost or even optimised to work directly on the database)
- the rebuild code (a routine that rebuilds only the necessary profiles)
- the code for the daemon (a lightweight pieace of control code that can handle the events described above, errors, logs etc).
Coranto addons:
* GuestPost, one click guestposting
* MoveIt!, Advanced Backup and site transfer
* PartialRebuild, CPU-friendly enhancement of FullBuild
* URLColumn, URLs for multiple Categories/Profiles
* Tickit!, Javascript News Tickers/Faders for Coranto!
* AddonEnabler, enables or disables single, multiple or all addons in one go
* SubmitMultiple, post consecutive news in an automatic loop!
* RSSAdvanced, RelatedNews ....

Get them at: http://coranto.gweilo.org/addons/
cerberos76_
 
Posts: 1339
Joined: Sun Mar 10, 2002 1:21 am

Postby msbzdragn » Wed Feb 09, 2005 3:00 pm

Moved to the correct forum.
Michael R. Tomkins
Administrator, 'Unofficial Coranto / NewsPro Forums'

Mitsubishi Diamante Forum

Do NOT send me instant messages asking for Coranto help without me telling you explicitly to do so. You WILL be placed on ignore if you do so; I don't have time to provide personal tech support to every person who IM's me. Sorry!
User avatar
msbzdragn
 
Posts: 2397
Joined: Mon Mar 11, 2002 4:51 pm
Location: Oak Ridge, TN

Postby deedub » Tue Aug 02, 2005 3:22 pm

Yoshi, are you still working on this? I would love to be able to do this sort of thing.
deedub
 
Posts: 12
Joined: Fri Jul 22, 2005 4:49 am

Postby Yoshi » Tue Aug 02, 2005 3:29 pm

Hi deedub,

yes I did manage to get this working!

it only took a simple perl script (If i recall I did need some additional CPAN modules installed by my ISP)

and a mail filtert setup to pipe incomming mail to the perl script.
If your host uses cpanel, or you run your own server this should be pretty straight forward.

I did this a loooong time ago so it may take while to come back to me ;-)
Yoshi
 
Posts: 40
Joined: Thu May 01, 2003 11:18 am

Postby Parahead » Thu Aug 04, 2005 12:00 pm

Yoshi wrote:I did this a loooong time ago so it may take while to come back to me ;-)
It would be really appreciated if you published the solution once it comes back to you... ;-)
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Yoshi » Thu May 11, 2006 2:31 pm

Just looking around I found this old post, not been around these parts for a while but I still use coranto! anyway I thought I would post my solution. Been setup for over a year or so and I never had any problems with security or dodgy posts appearing on my site

This is how I did it. I am no programmer and what I have here is a mish mosh of a script I found for posting to greymatter via email.

I cant provide support or garauntees that this will either work or that it won't break anything else. SO MAKE A BACKUP FIRST or try it out on a copy of your setup!

First off you need cerberos76 Guestpost addon setup and configured.
I am using coranto 2.4 and guestpost build 9

My web host uses cpanel so thats the limit of my knowledge:-
You dont need to create an actual email account, just setup a email filter that looks like
Code: Select all
header:-
$header_to: contains "whatever_you_want_the_address@your_domain"

Code: Select all
destination:-
|/home/yourpath/to/cgi-bin/whateveryoucallthescriptbelow.pl -e -q

the -e & -q are switches you can see what they do in the script below
e Optional. send errors via an email reply. & -q Optional. suppresses non-error output


Code: Select all
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);

#your SMTP server if other than localhost(used for error emails using -e option)
#(set this if the system rgmp is installed on does not have it't own SMTP server)
$smtp_server = "localhost";

#need to keep the backslahs
$sender = "address\@domain";

#author name can be set here or in the email
$authorname = "";

#Password either set here or in the email
$authorpassword = "";

#Category
$ncategory="";

#I have a custom filed called CustomFiled_exurl if a url is passed the news title links offsite (use as an example of handling additional custom fileds
$nexurl="";

# Yes means you get an email back confirmin it has been processed No means you dont
$nconfirm="";

#Url path to your coranto script
$server_url = "http://www.yourdomain/your coranto_folder/coranto.cgi";

###########################################################

$version = "1.3";

use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
use Mail::Sendmail;


#take input from STDIN if no file specified.
$input_file = "-";
$quiet = "0";
$moretext="";

$usage_text = <<USAGE;
\nRGMP Version $version
USAGE: $0 [options]
\tOptions:
\t\t-A author name
\t\t-P author password
\t\t-e
\t\t-f input file
\t\t-h
\t\t-n
\t\t-p http proxy
\t\t-q
\t\t-s URL to gm.cgi
\nNOTES:
\t-A Optional. Username for logging in to Greymatter,
\t   if not specified here, must be given in input text.
\t-P Optional. Password, same as above.
\t-e Optional. send errors via an email reply.
\t-f Optional. if omitted, uses STDIN.
\t-h This help message.
\t-n Optional. Remove newlines from post.
\t-p Optional. format: http://proxy.my.org:8080/
\t-q Optional. suppresses non-error output
\t-s Required if not set in RGMP code.\n\n
USAGE

#####

&get_args;

&info_out("Will post to: $server_url\n");

&get_post;

#change 0 to 1 for debugging purposes.
if(0){
   print  "authorname: $authorname\n";
   print  "authorpassword: $authorpassword\n";
   print  "subject: $subject\n";
   print  "maintext: >>$maintext<<\n";
   print  "moretext: >>$moretext<<\n";
   print  "allowkarma: $allowkarma\n";
   print  "allowcomments: $allowcomments\n";
   print  "stayattop: $stayattop\n";
   print  "makelinks: $makelinks\n";
   exit;
}

$ua = LWP::UserAgent->new;

if( $http_proxy ){
   if( lc($http_proxy) eq "env"){
      $ua->env_proxy; # initialize from environment variables
   }else{
      $ua->proxy(http  => "$http_proxy");
   }
}
#change the guestpost_posteremail to whatever address you want the confirmation to come from
#you may also want to remove the reference to CustomFiled_exurl
$http_request = POST "$server_url", [ action => 'login', secondaryaction => 'submitsave', uname => "$authorname", pword => "$authorpassword", Category => "$ncategory", Subject => "$subject", Text => "$maintext", CustomField_exurl,=> "$nexurl", guestpost_postername => 'yoshi', guestpost_posteremail => 'lee@0-21.co.uk' ] ;
 

&info_out("Posting...");
 
my $res = $ua->request($http_request);

  # check the outcome
  if ($res->is_success) {
 
     &info_out("Post successfull\n");
    &confirm_post();
  }
  else {
    &error_out( "Post failed!\nUnknown error, this may help:\n\n".substr($post_results,0,300)."\n\n");
  }


#thats it! wow, pretty simple.
exit;

##########################

sub get_args(){
   # it is now possible to not need any command line arguments
   if(@ARGV != 0){
   
      @args = reverse(@ARGV);
      while($arg = pop @args){
         if( lc($arg) eq "-s"){ $server_url = pop(@args);  }
         elsif( $arg eq "-p"){ $http_proxy = pop(@args);  }
         elsif( lc($arg) eq "-f"){ $input_file = pop(@args);  }
                   elsif( lc($arg) eq "-h"){ info_out($usage_text); exit;  }
                   elsif( lc($arg) eq "-q"){ $quiet = 1;  }
         elsif( lc($arg) eq "-e"){ $email_errors = 1; }
         elsif( lc($arg) eq "-n"){ $no_newlines = 1; }
                   elsif( $arg eq "-A"){ $authorname = pop(@args);  }
                   elsif( $arg eq "-P"){ $authorpassword = pop(@args);  }
         else{
            &error_out("\nUnknown option '$arg'\n$usage_text");
            exit;
         }
      }   
   }
}


sub get_post(){
   my $simple_post=0;
   my $body;
   if( ! open (IN,$input_file) ){
      &error_out("Could not open input file: $input_file !\n");
      exit;
   }
   while(<IN>){
         if(/^From:\s+(.+)$/){
         $email_from = $1;
      }
      if(/^Subject:\s+(.+)$/){
         $subjectline = $1;
         if ($subjectline =~ /^\{([^\}]*)\}\s*(.*)$/ ){
                 $subject=$2;
                 $authdata = $1;
                 if($authdata =~ /username\s*\=\s*(\w+)/){$authorname=$1;$simple_post=1;}
                 if($authdata =~ /password\s*\=\s*(\w+)/){$authorpassword=$1;$simple_post=1;}
               if($authdata =~ /category\s*\=\s*(\w+)/){$ncategory=$1;$simple_post=1;}
               if($authdata =~ /confirm\s*\=\s*(\w+)/){$nconfirm=$1;$simple_post=1;}
         }elsif($subjectline =~ /[\{\}]/ ){
            &error_out("I'm confused, check your subject line and try again\nSubject: $subjectline\n");
            exit;
         }else{
                 $subject=$subjectline;
         }
         #check for wrapped subject line.
         $file_pos = tell(IN);
         $_ = <IN>;
         if( /^\s(.+)$/ ){
            $subject=$subject.$1;
         }else{
            seek (IN,$file_pos,0);
         }
      }
         if(/^From:\s+(.+)$/){
         $email_from = $1;
      }
      #skip rest of headers
      if(/^\n$/){ last; }
   }
   if( $simple_post ){
      #gobble up body of message
           while(<IN>){
         $maintext .= $_;
              }
         }
   else {      
      while(<IN>){
         $altmaintext .= $_;

         if( /\s*username\s*=\s*(\S+)\s*/is ){
            $authorname = $1;
         }
         if( /\s*password\s*=\s*(\S+)\s*/is ){
                           $authorpassword = $1;
                   }
         if( /\s*category\s*=\s*(\S+)\s*/is ){
                           $ncategory = $1;
                   }
         if( /\s*exurl\s*=\s*(\S+)\s*/is ){
                           $nexurl = $1;
                   }
         if( /\s*confirm\s*=\s*(\S+)\s*/is ){
                           $nconfirm = $1;
                   }
         if ( /^\{maintext\}/i  ){
            $found_maintext++;
            while(<IN>){
               if(  /^\{moretext\}/i ){
                  last;
               }else{
                  if ( /^\{end\}/i  ){
                         last;
                  }
                  $maintext .= $_;
               }
            }
            
         }
         if ( /^\{moretext\}/i  ){
            $found_moretext++;
            #{moretext} goes to the end of the message
                                while(<IN>){
               if ( /^\{end\}/i  ){
                      last;
               }
               $moretext .= $_;
                                }
               }
         
      }   
      if(! $found_maintext && ! $found_moretext){
                     #&error_out("Could not find {maintext} in message body!?!? Check your message format and spelling.\n");
         #exit;
         $maintext = $altmaintext;
         if( ! $maintext =~ /\S/s ) {
            &error_out("E-gads, Could not find any message body!?!?\n");
            exit;
         }
         
           }
   }
   close IN;

   if(! $server_url ){
             &error_out("\nNo server URL specified anywhere.\n");
                  exit;
   }
   if( ! $authorname ){
      &error_out("No username specified.\n");
      exit;
   }
   if( ! $authorpassword ){
      &error_out("No password specified.\n");
      exit;
   }
      if( ! $ncategory ){
      &error_out("No category specified.\n");
      exit;
   }


   # strip out newline chars if requested
   if( $no_newlines ){
      $maintext =~  s/\n/ /gs;
      $moretext =~  s/\n/ /gs;
   }
}



sub info_out(){
   if( ! $quiet ){
      print $_[0];
   }
}


sub error_out()
{
if( $email_errors && $email_from ){
      $rx = $Mail::Sendmail::address_rx;
      # use the handy built-in, military strength regex   
       if ( $email_from =~ /$rx/) {
               $address=$&;
      }

  %mail = (
      To      => "$email_from",
      From    => "$sender",
      #Bcc     => 'Someone <him@there.com>, Someone else her@there.com',
      # only addresses are extracted from Bcc, real names disregarded
      #Cc      => 'Yet someone else <xz@whatever.com>',
      # Cc will appear in the header. (Bcc will not)
      Subject => "News Post ERROR: RE: $subject" ,
Message => "ERROR:\n$_[0]\n\n\nsubject: $subject\nmaintext: >>$maintext\n\nexternalURL: $nexurl\ncategory: $ncategory\n",
      'X-Mailer' => "Mail::Sendmail version $Mail::Sendmail::VERSION",
  );


  $mail{Smtp} = "$smtp_server";

if( ! sendmail(%mail) ){
          #can't send email, lets just dump to STDERR like we should.
         print STDERR "ERROR:\n$_[0]\n\n";
         print STDERR "ERROR:\n Could not send email!\n $Mail::Sendmail::error\n";
         exit;
      }
   }
}

sub confirm_post()
{
if( $nconfirm eq "yes" && $email_from ){
      $rx = $Mail::Sendmail::address_rx;
      # use the handy built-in, military strength regex   
       if ( $email_from =~ /$rx/) {
               $address=$&;
      }

  %mail = (
      To      => "$email_from",
      From    => "$sender",
      #Bcc     => 'Someone <him@there.com>, Someone else her@there.com',
      # only addresses are extracted from Bcc, real names disregarded
      #Cc      => 'Yet someone else <xz@whatever.com>',
      # Cc will appear in the header. (Bcc will not)
      Subject => "News Post Success: RE: $subject" ,
Message => "\nsubject: $subject\nmaintext: >>$maintext\n\nexternalURL: $nexurl\ncategory: $ncategory\n",
      'X-Mailer' => "Mail::Sendmail version $Mail::Sendmail::VERSION",
  );


  $mail{Smtp} = "$smtp_server";

if( ! sendmail(%mail) ){
          #can't send email, lets just dump to STDERR like we should.
         print STDERR "ERROR:\n$_[0]\nFor dubug sender is: $sender\nFor dubug To is: $email_from\n";
         print STDERR "ERROR:\n Could not send email!\n $Mail::Sendmail::error\n";
         exit;
      }
   }
}



The above works for me. As I said before, I did this a loooong time ago, so I don't recall the exact setup, don't think I needed to do anything to the guestpost addon.

If you get probs or it doesn't work let me know and I'll have a deeper poke around.

oh yea you'll need to know the format of the email
username = [username as defined in guestpost addon]
password = [password as defined in guestpost addon]
category = [your category]
exurl = [you proabably dont need this]
confirm = [yes or no (get a confirmation email back or not)]
{maintext}
this is a test message
this is a test url http://www.0-21.co.uk <http://www.0-21.co.uk/> this
is a tet line break
{end}

send the email to whatever email address you setup for the email filter, the title of the email will be the title of your news item.

Hope this works for you
Yoshi
 
Posts: 40
Joined: Thu May 01, 2003 11:18 am

Postby SrNupsen » Fri May 12, 2006 12:00 am

Wow - impressing piece of backtracking user-friendliness!!

SrNupsen :)
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway

Postby Yoshi » Fri May 12, 2006 11:03 am

Ah well, I try :D
If anyone improves on this please let me know :!:
Yoshi
 
Posts: 40
Joined: Thu May 01, 2003 11:18 am

Postby Pirate Elf » Fri May 12, 2006 7:54 pm

interesting. Perhaps I can take a look and see what we can do to clean it up some and make it a bit easier. Doubtful but there is always hope right?
Nichts ist für dich
Nichts war für dich
Nichts bleibt für dich
Für immer
Pirate Elf
 
Posts: 732
Joined: Wed Jan 31, 2007 9:45 pm

Postby Yoshi » Sun May 14, 2006 5:38 pm

hee, it's not at all doubtful. I suspect plenty of tidying can be done and a dozen or so improvments, but as a starter for ten, it works. :shock:
Yoshi
 
Posts: 40
Joined: Thu May 01, 2003 11:18 am

Previous

Return to Addon Development and Requests

Who is online

Users browsing this forum: No registered users and 2 guests

cron