PHP code example of devsrealm / csskiller-plugin-mail-contract

1. Go to this page and download the library: Download devsrealm/csskiller-plugin-mail-contract 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/ */

    

devsrealm / csskiller-plugin-mail-contract example snippets


use CSSKillerMailContract\services\TokenSignatureService;

// Generate a confirmation token
$service = new TokenSignatureService($core);
$token = $service->generateToken('[email protected]', [
    'ip_address' => $_SERVER['REMOTE_ADDR'],
    'user_agent' => $_SERVER['HTTP_USER_AGENT']
]);

// Generate a full confirmation link
$confirmation = $service->generateConfirmationLink(
    email: '[email protected]',
    baseUrl: 'https://yoursite.com/terms/confirm',
    metadata: ['source' => 'registration']
);

// Validate a token
$result = $service->validateToken($token);
if ($result['valid']) {
    // Mark as confirmed
    $service->markAsConfirmed($token, $_SERVER['REMOTE_ADDR']);
}

// Get all tokens for an email
$tokens = $service->getTokensByEmail('[email protected]');

$confirmation = $service->generateConfirmationLink(
    email: $email,
    baseUrl: $baseUrl,
    metadata: [
        'custom_field' => 'value',
        'user_id' => 123,
        'campaign' => 'newsletter_signup'
    ]
);

src/
├── PluginEntry.php              # Plugin registration
├── Routes.php                   # Route definitions
├── controllers/
│   └── TermsAcceptanceController.php
├── services/
│   └── TokenSignatureService.php
├── commands/
│   └── CleanupExpiredTokensCommand.php
├── middlewares/
│   └── AuthMiddleware.php
└── templates/
    ├── terms-form.html
    ├── terms-success.html
    └── terms-error.html