PHP code example of remp / mailer-module

1. Go to this page and download the library: Download remp/mailer-module library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

remp / mailer-module example snippets


$configurator = new Nette\Configurator;
$configurator->addConfig(__DIR__ . '/../vendor/remp/mailer-module/src/config/config.root.neon');
// ... rest of the configuration

    class UrlParserGenerator implements IGenerator
    {
        // ...
        public function generateForm(Form $form)
        {
            // ...

            $form->addTextArea('articles', 'Article')
                ->setAttribute('rows', 7)
                ->setOption('description', 'Paste article URLs. Each on separate line.')
                ->getControlPrototype()
                ->setAttribute('class', 'form-control html-editor');

            // ...
        }
    

    class UrlParserGenerator implements IGenerator
    {
        // ...
        public function process($values)
        {
            $sourceTemplate = $this->sourceTemplatesRepository->find($values->source_template_id);

            $items = [];
            $urls = explode("\n", trim($values->articles));
            foreach ($urls as $url) {
                $url = trim($url);
                $meta = $this->content->fetchUrlMeta($url);
                if ($meta) {
                    $items[$url] = $meta;
                }
            }

            $params = [
                'intro' => $values->intro,
                'footer' => $values->footer,
                'items' => $items,
                'rtm_campaign' => $values->rtm_campaign,
            ];

            $engine = $this->engineFactory->engine();
            return [
                'htmlContent' => $engine->render($sourceTemplate->content_html, $params),
                'textContent' => strip_tags($engine->render($sourceTemplate->content_text, $params)),
            ];
        }
    }
    

    class NewsfilterGenerator implements IGenerator
    {
        // ...
        public function getWidgets()
        {
            return [NewsfilterWidget::class];
        }
    }
    

    class UrlParserGenerator implements IGenerator
    {
        // ...
        public function apiParams()
        {
            return [
                new InputParam(InputParam::TYPE_POST, 'source_template_id', InputParam::REQUIRED),
                new InputParam(InputParam::TYPE_POST, 'articles', InputParam::REQUIRED),
                new InputParam(InputParam::TYPE_POST, 'footer', InputParam::REQUIRED),
                new InputParam(InputParam::TYPE_POST, 'rtm_campaign', InputParam::REQUIRED),
                new InputParam(InputParam::TYPE_POST, 'intro', InputParam::REQUIRED)
            ];
        }
    }
    

    class NewsfilterGenerator implements IGenerator
    {
        // ...
        public function preprocessParameters($data)
        {
            $output = new \stdClass();

            if (!isset($data->post_authors[0]->display_name)) {
                throw new PreprocessException("WP json object does not contain            $output->editor = $author->display_name;
                $output->from = $author->display_name . ' <' . $author->user_email . '>';
                break;
            }

            if (!isset($data->post_title)) {
                throw new PreprocessException("WP json object does not contain  not contain 

    return "my-provider";
    

    return [
        [
            'name' => String, // user friendly label
            'provider' => String, // should be same as result of provider()
            'code' => String, // machine friendly name, slug
            'group' => [
                'id' => Integer, // ID of segment group
                'name' => String, // user friendly label of group
                'sorting' => Integer // sorting index; lower the number, sooner the group appears in the list
            ]
        ],
    ];
    

  [
      'provider' => String, // identification of segment provider
      'code' => String, // segment code
  ]
  

  return [
      Integer,
      Integer,
      // ...
  ]
  

  return [
      $userId => [
          'id' => String, // userId
          'email' => String, // valid email address of user

          // you can provide optional data that can be used within your email templates, for example:
          'first_name' => String,
          'last_name' => String,
      ],
  ];
  

$response = $this->client->post(self::ENDPOINT_LIST, [
    'form_params' => [
        'user_ids' => Json::encode($userIds),
        'page' => $page,
    ],
]);
$result = Json::decode($response->getBody(), Json::FORCE_ARRAY);

  [
    "autologin_token": "foo",
    "mail_sender_id": "baz",
  ]
  

  [
    "autologin_token": "%recipient.autologin_token%",
    "mail_sender_id": "%recipient.mail_sender_id",
  ]
  

  [
    "autologin_token": "foo",
    "mail_sender_id": "baz",
  ]
  

* * * * * php /home/remp/workspace/remp/Mailer/bin/command.php mail:process-job

* * * * * php /home/remp/workspace/remp/Mailer/bin/command.php mail:job-stats

https://predplatne.dennikn.sk/mail/mail-settings/un-subscribe-email/newsletter_daily?rtm_source=newsletter_daily&rtm_medium=email&rtm_campaign=daily-newsletter-11.3.2019-personalized&rtm_content=26026
shell
curl -X GET \
  http://mailer.remp.press/api/v1/mailers/mail-types?public_listing=1&code=demo-weekly-newsletter \
  -H 'Authorization: Bearer XXX'
shell
curl -X GET \
  http://mailer.remp.press/api/v1/mailers/mail-types?public_listing=1&code[]=demo-weekly-newsletter \
  -H 'Authorization: Bearer XXX'
shell
curl -X GET \
  http://mailer.remp.press/api/v1/mailers/mail-types?public_listing=1&code[]=demo-weekly-newsletter \
  -H 'Authorization: Bearer XXX'
shell
curl -X GET \
  http://mailer.remp.press/api/v1/mailers/mail-type-categories \
  -H 'Authorization: Bearer XXX'
shell
curl --location --request GET \
'mailer.remp.press/api/v1/mailers/templates?mail_type_codes[]=onboarding&mail_type_codes[]=system&with_mail_types=true&page=1&limit=5' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer XXX'
shell
curl -X POST \
  http://mailer.remp.press/api/v1/mailers/jobs \
  -H 'Authorization: Bearer XXX' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'template_id=24832&segment_code=users_with_print_in_past&segment_provider=crm-segment&context=123&mail_type_variant_code=variant-1&start_at=2023-12-29T10:05:00Z'