Results 1 to 16 of 16

Thread: [zad_sendnews] New extension for posting news by email

  1. #1
    New user
    Join Date
    08-21-11.
    Posts
    19

    Default [zad_sendnews] New extension for posting news by email

    This utility allows you to post news sent by email.

    You can set:
    • the mail server from which to read emails (POP3/IMAP);[/*:m:39t047i0]
    • the news archive where to post contents;[/*:m:39t047i0]
    • the author for posted news;[/*:m:39t047i0]
    • whether to include file attachments (and where files are saved);[/*:m:39t047i0]
    • how often to check for new emails;[/*:m:39t047i0]
    • automatic publication of news (immediate, delayed for one day or more, suspended);[/*:m:39t047i0]
    • the action to take on emails after posting the news (delete, log to file, move to another folder of the mailbox).[/*:m:39t047i0]


    You can also add filters on news fields, using the a regular expression or predefined actions.

    Besides, you can do an automatic conversion of file attachments to PDF documents, specifying which types of files to convert. To use this feature, the system requirements are:
    • Open Office (version >= 3.x) installed and running as a service on port 8100;[/*:m:39t047i0]
    • Python installed with the Python-UNO-bridge extension.[/*:m:39t047i0]

  2. #2
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: [zad_sendnews] New extension for posting news by email

    Wow. I was going to build this, but you have done an excellent job. Thanks.

    There are a few things I would like to have, if you can include that would be great.

    1. How can we map image attachments to the IMAGE field.

    2. Also, I'd like to store any attachments and/or images in a special folder under the folder setting, e.g.
    tl_files/content/news/201102/

    So an additional setting to [x] Add custom folder, then select [ YYYY ], [ YYYYMM ] , [ YYYYMMDD ] would be excellent (as this is more manageable when you need to delete old news and then the matching old news images/files as well.

    3. Mac Mail stores attachments and images as inline, so would it be possible to extract those and map to "image"

    4. There is a news_gallery extension and another setting could add support for that. e.g. [Map all images to News Gallery], [Map all images, except first to News Gallery]

    Otherwise great stuff.

    PS. Do we have to create rules, or maybe there could be some default rules. I can see how this is going to become a bit tedious to setup on every server.

  3. #3
    New user
    Join Date
    08-21-11.
    Posts
    19

    Default Re: [zad_sendnews] New extension for posting news by email

    Quote Originally Posted by thyon
    Wow. I was going to build this, but you have done an excellent job. Thanks.
    There are a few things I would like to have, if you can include that would be great
    ....
    :D
    Ok, I'll try to do all for the next release.

    Quote Originally Posted by thyon
    PS. Do we have to create rules, or maybe there could be some default rules. I can see how this is going to become a bit tedious to setup on every server.
    If you don't use any rules, it is ok: all emails are inserted without any change. So that, the email subject becomes the news title and the email content becomes the news content. The news teaser remains void. Besides, for the news content is used the HTML text of the email, but if it doesn't exists, it is used the plain text.

    Maybe it is better to create an import/export function for all settings... I added to the wish-list.

  4. #4
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: [zad_sendnews] New extension for posting news by email

    You can look at how e_Up extracts the images and files and stores them in the tl_files folder. You can then use that method to extract the images and files from an e-mail to add the News Image and/or add enclosures.

    http://www.contao.org/en/extension-list ... 09.en.html

  5. #5
    New user
    Join Date
    08-21-11.
    Posts
    19

    Default [zad_sendnews] Updated: extension for posting news by email

    This utility allows you to post news sent by email.

    You can set:
    • the mail server from which to read emails (POP3/IMAP);[/*:m:1zmewyd2]
    • the news archive where to post contents;[/*:m:1zmewyd2]
    • the author for post[/*:m:1zmewyd2]
    • ed news;[/*:m:1zmewyd2]
    • whether to include file attachments (and where files are saved);[/*:m:1zmewyd2]
    • how often to check for new emails;[/*:m:1zmewyd2]
    • automatic publication of news (immediate, delayed for one day or more, suspended);[/*:m:1zmewyd2]
    • the action to take on emails after posting the news (delete, log to file, move to another folder of the mailbox).[/*:m:1zmewyd2]

    You can also add filters on news fields, using the a regular expression or predefined actions.

    Besides, you can do an automatic conversion of file attachments to PDF documents, specifying which types of files to convert. To use this feature, the system requirements are:
    • Open Office (version >= 3.x) installed and running as a service on port 8100;[/*:m:1zmewyd2]
    • Python installed with the Python-UNO-bridge extension.[/*:m:1zmewyd2]


    Now the text in HTML format of an email can contain images linked to attachments: the image URL will be replaced with the actual URL of the image uploaded.
    In this way you can easily add images to you news.

    Download extension link:
    http://www.contao.org/en/extension-l...000039.en.html

    ----- A MINIMAL GUIDE -----

    Prerequisites for using Sendnews extension:
    1) IMAP php module installed in your system;
    2) knowledge of mail server settings for the mailbox you want to use.

    Steps for setting a Sendnews manager:
    1) click on Send News link in the backend module list (left side of the page);
    2) on the Send News page, click on NEW link to create a new sendnews manager;
    3) add the required settings:
    - title: the Send News manager name;
    - server name: your mail server name;
    - server port: 0 (default);
    - server type: POP3 or IMAP;
    - security: choose server security protocol;
    - username/password: user/password to access the mailbox;
    - folder: leave blank (default);
    - news archive: choose the news archive where to post the imported news;
    - author: choose a Contao user as author of the imported news;
    - attachements: if allowed, choose the folder where save files;
    - check time: choose time interval for checking mailbox;
    - automatic publishing: choose when to publish imported news;
    - final action: delete emails is the default;
    - enable: enable the sendnews manager.

    For a simple use of the Send News extension you don't need to add any rules.

    To test the Send News manager:
    1) send a new email to the configured mailbox;
    2) click on check email button (a mail envelope icon) to immediatly poll email server;
    3) read the showed report.

    When you find a login error to your mailbox:
    - check user/password;
    - check the server type (POP3 or IMAP);
    - try another security protocol (more used protocols: NONE, SSL without certificates, TSL without certificates, TLS if present without certificates).

    How to add images to your news:
    During creation of a new email, simply add an image to the text to send. Don't add the image as attachment, but insert it into the formatted text.
    Try in this way: copy an image from another document (i.e. a word document or a web page) and paste into the email text.
    Usually your email reader do all the job:
    - add the image as attachment;
    - in the HTML text of email, add a inner link to attached image.

    The Send News extension recognizes these inline linked images and correctly shows them in your website.

  6. #6
    New user
    Join Date
    08-21-11.
    Posts
    19

    Default Re: [zad_sendnews] New extension for posting news by email

    See new version of Send News extension:
    http://www.contao-community.org/view...hp?f=21&t=4117

  7. #7
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: [zad_sendnews] Updated: extension for posting news by em

    1. Main News Image
    I would like to suggest something else. Instead of just adding the message as inline into the news content, why not have a setting that allows the first image that appears inline to be attached as the News Image (so it can be used as the thumbnail in the News List).

    2. News Gallery Images
    Should the News Gallery extension be installed, would it be possible to flag the images #2, #3, etc. as images as part of the news_gallery images.

    3. Would it be possible to add the images in a folder in the tl_files area which is created using a template like 201205/ (year-month), e.g.
    201205/thisismynewsimage.jpg

    4. The alias always creates with a number behind it. This is not correct according to the Contao standard alias feature. This means that an e-mail isn't enough, you're still required to logon to correct the alias value, by removing the auto-id addition. Normally this is only done, if the alias already exists in the DB.

    5. I'm also unable to auto-extract the teaser from the HTML mail message, even though I've specified div,span,p,em,strong as my tag parameters.

  8. #8
    New user
    Join Date
    08-21-11.
    Posts
    19

    Default Re: [zad_sendnews] Updated: extension for posting news by em

    1. Main News Image
    3. Image's folder
    4. Alias
    Ok. Scheduled for the next version.

    2. News Gallery Images
    Probably I need more time to understand how "News Gallery" extension works.

    5. auto-extract the teaser
    :?
    I did some tests and I found a bug.
    I'll fix it in the next version.

  9. #9
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: [zad_sendnews] Extension for posting news by em

    All you can do is detect the multiSRC field to see if news gallery is installed and then just add the file list as an array to the UPDATE statement, that will auto-serialize.

    Thanks for the consideration on the other features.

  10. #10
    New user
    Join Date
    08-21-11.
    Posts
    19

    Default [zad_sendnews] New extension for posting news by email

    Added in Contao repository the new version of Zad Sendnews.

    Version 1.1.0 stable (2012-06-06)
    ---------------------------------
    CHANGELOG:
    - Added: now you can group attachments by year, by month, by day or not at all.
    - Added: now you can choose different ways to add images to news.
    - Fixed: append to the alias the news id only if the alias already exists in the database.
    - Fixed: report is saved to system log when email checking is executed by cron.
    - Fixed: automatic teaser action now works.
    - Fixed: minor bugs.

    This is the download page:
    http://www.contao.org/en/extension-l...010009.en.html

  11. #11
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: [zad_sendnews] New extension for posting news by email

    Hey. Fantastic. I love the changes. Thank you for that.

    I finally decided to dig into the code and fix a couple of small problems to make it ready for production.

    1. I decided to make the date options a config setting, so people can change it themselves to a format they prefer.
    config.php
    Code:
    /**
     * ZAD folder formats
     */
    $GLOBALS['TL_ZAD']['formats']['year']		= 'Y';
    $GLOBALS['TL_ZAD']['formats']['month']	= 'Ym';
    $GLOBALS['TL_ZAD']['formats']['day'] 		= 'Ymd';
    Then add this to the ZadSendNewsManager.php
    Code:
    private function check()
    ...
    ...
    
          // set attachment folder
          $this->folder = $this->manager->enclosure_dir;
    
          // modified by thyon
          $this->folder .= '/' . date($GLOBALS['TL_ZAD']['formats'][$this->manager->enclosure_dirtype], time());
    
          // fix the directory check function
          if (!is_dir(TL_ROOT . '/' . $this->folder)) {
            // create directory
            mkdir($this->folder);
          }      
    ...
    }
    2. set an automatic teaser anyway, even if there isn't a rule

    Code:
    private function importNews() {
    ...
        // add default auto-teaser at first full stop or 80 chars
        $this->import('String');
        $pos = max(80, (strpos($this->text, '.')+1));
        $this->news['teaser'] = $this->String->substr($this->text, $pos, ($pos == 80));
    ...
    }
    3. Remove the inline image if it was inserted as main image (singleSRC). I would also remove the floating=left setting, because I normally control that via CSS, so it's just not necessary to set that up.

    Code:
    private function imageManagement(&$import) {
    ...
            case 'first':
              if ($first) {
                // save as news icon
                $filename = $this->saveFile($img);
                $import['addImage'] = '1';
                $import['singleSRC'] = $filename;
                //$import['floating'] = 'left';
                // remove image from list
    		$search = array(
    		          '#<img(\s[^>]*)?\ssrc\s*=\s*"cid:'.$img['cid'].'"(\s[^>]*)?>#is',
    		          '#<img(\s[^>]*)?\ssrc\s*=\s*"'.$img['cid'].'"(\s[^>]*)?>#is');
    	        $replace = '';
    	        $count = 0;
    	        $this->news['html'] = preg_replace($search, $replace, $this->news['html'], -1, $count);
              } else {
                // save as file attachment
                $this->news['files'][] = $img;
              }          
              break;
    ...
    }
    Now it's ready for production to my clients. Thanks. Thanks. Thanks.

  12. #12
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: [zad_sendnews] New extension for posting news by email

    I've found some bugs and improvements in my code.

    the mkdir code is wrong. Here is the fix:
    Code:
    mkdir(TL_ROOT . '/' . $this->folder);
    The auto-teaser can be modified to look for the first "." (using my example above) or the first paragraph (see below), which looks for the first newline character.

    Code:
    $this->import('String');
        $pos = max(80, (strpos($this->text, "\n")));
        $this->news['teaser'] = $this->String->substr($this->text, $pos, ($pos == 80));
    Also in the code for the image insertion, I removed the float, but I wanted to add the fullsize=1, which some people might want to do. perhaps we can just loop through the DCA default settings to do these, otherwise we have to provide an interface for this.

    More improvements:
    How can we process e-mails with just a intro paragraph and then a hyperlink, pointing to an external link, which should automatically process the link, change the mode to external and open in a new window. Otherwise, it will process as a normal e-mail with a link INSIDE the default text. Maybe we add the link as the first entry, which could be the trigger.

    Lastly, I wanted to know if we could add some type of code to make it process differently, e.g. a CODE. Sometimes there might be three blog archives which could collect from the same mailbox (mailboxes are expensive here in south africa, and having 1 for each blog seems unecessary). we could perhaps implement this as aliases? blog1@domain=>blog@domain, blog2@domain => blog@domain, but we have access to the alias value in the sender field, e.g. blog1 and blog2, which we can use to discriminate the e-mail (or use a subject code [2], where 2 would be the news archive ID and it gets stripped away, if it exists.

    This presents problems as well when you want to use the mailbox for multiple send news processors, because the first one might delete the e-mail (i guess you can set it up for the last one to delete, but you have to somehow know which is the last one in the processing list, as you might be processing it in ID sorting, but the tl_zad_sendnews is listed by name.

  13. #13
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: [zad_sendnews] New extension for posting news by email

    Hi trinko

    I've attached my latest update to your extension. It adds a working version of the gallery (using your language strings, I inferred how you wanted to use it).

    Also, I've added DCA support to the image and gallery settings, so if you set them up in the DCA or dca config, they will be used as the default values, otherwise just blank values (instead of NULLs).

    Also, I've included all the bugs. The auto-teaser now it by "\n" newline.

    It works really, really well.. Now we just have to find a secret key in the subject to prevent spammers from flooding the mailbox.

    UPDATE: I've deleted the ZIP file, please find the download link further below.

  14. #14

    Default Re: [zad_sendnews] New extension for posting news by email

    Hi there, Can you please post the attachment "zad_sendnews.zip" once again. The download link is broken but the counter is active. Thanks
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  15. #15
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: [zad_sendnews] New extension for posting news by email

    Here is the download URL from my website (not uploaded).


    http://www.thyon.com/tl_files/content/l ... ndnews.zip

  16. #16

    Default Re: [zad_sendnews] New extension for posting news by email

    thanks thyon.
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

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
  •