Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New functionalities: Templating, Languages, Logging, Previewing, Cors #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Elfangor93
Copy link

@Elfangor93 Elfangor93 commented May 2, 2022

Thank you @e-dschungel very much for this very handy script. I much appreciate using this script in several web projects. But I am missing some functionalities which I implemented and would like to share with you...

With this pull request, I would like to add some functionalities to the rssgoemail project. The following functionalities are added:

Templating

In the config file there is a new configuration called templateType. When switching this configuration from stringstring to tmpltmpl a templating mechanism is activated. This means that the email body will now be created by applying a given tempate file instead of just performing a search and replace on some placeholders. Two default template files are given in the folder /tmpl/ with the names email.php and item.php. Where item.php is the template file for one feed item and email.php is the template file for the assembled list of feed items to be sent.
Inside the template files, dynamic content can be added using the following possibilities:

  • <?php echo $rge_config['<param>']; ?>: inserting any parameter value from the configuration
  • <?php echo $content['##FEED_COPYRIGHT##']; ?>: inserting dynamic content from the rss feed (see available Placeholders)
  • <?php echo text('unsubscribe_lbl'); ?>: inserting translatable static content (see Languages functionality)

Languages

The text() function allows to translate content available in the /tmpl/language.php file. This file consists of an array with all available languages as entries. Inside each language entry there are language constants and their corresponding translations.
Now, by applying the function text('readMore'), the translation of the readMore will be returned based on the language chosen in the configuration: $rge_config['language'].

Logging

There is a new file /log/mail.log where logging happens. Everytime the rssgoemail script is executed one logging entry will be created telling you if the email was sent successfully or the raised error message if not.

Previewing

Before sending a feed email to a lot of subscribers its useful to send the email to your own email address to check if the email gets generated correctly. You can enter the preview mode of the reegoemail script by passing the two request variables preview=true and email=<YOUR-ADDRESS> to the script. When in preview mode no guids are added to the data base. Therefore the feed items will be sent afterwards normally to your subscribers.

Cors

When cors is activated in the configuration (allowCors) the script can be executed by 3rd party application that is running on a different server. This way another webapp or website containing a send button can kick off the sending process.

Feel free to comment on this PR is you have any questions or found a bug. Would love to see these features making it into an official release from you one day...

@e-dschungel
Copy link
Owner

Hi,

thank you very much for your contribution. Here are my comments/thoughts.

Templating:
Ok, will be merged.

Languages:
Ok, I think a full blown internationalization would be overkill for this small script. This solution is quick and easy.

Logging:
Ok, will be merged.

Previewing:
I see the need, but I don't think sending mails to an address given by a URL parameter is a good idea. I would prefer an preview email address in the config, but lets discuss.

Cors:
Sorry, I did not get the use case here. Is it about embedding the HTML output of the script (which used to be just text because my use case is calling it from a cronjob) into a different website? The HTML mail content does not need that, right?

General:

  • Please add the new changes to README.MD
  • Please remove global constants (EMAIL_PREVIEW, etc.), use $rge_config or a different variable which is passed around
  • Please extend checkConfig function for new config options
  • Make sure check_code.sh runs without warnings.

If these points are resolved I'll be happy to merge your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants