PHP code example of palpalani / laravel-spamassassin-score
1. Go to this page and download the library: Download palpalani/laravel-spamassassin-score 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/ */
palpalani / laravel-spamassassin-score example snippets
return [
'api' => 'https://spamcheck.postmarkapp.com/filter',
// Default "long". Must either be "long" for a full report of processing rules, or "short" for a score request.
'option' => 'long'
];
use palPalani\SpamassassinScore\Facades\SpamassassinScore;
// Get spam score with default configuration
$result = SpamassassinScore::getScore($emailContent);
// The result will contain:
// - 'score': The spam score
// - 'success': Whether the check was successful
// Additional fields when using 'long' option format
use palPalani\SpamassassinScore\SpamassassinScore;
class EmailController extends Controller
{
public function __construct(
private SpamassassinScore $spamassassinScore
) {}
public function checkEmail(Request $request)
{
$result = $this->spamassassinScore->getScore($request->input('email'));
if ($result['score'] > 5.0) {
return response()->json(['message' => 'Email may be spam'], 400);
}
// Proceed with sending email
}
}
use palPalani\SpamassassinScore\SpamassassinScore;
$spamassassinScore = new SpamassassinScore();
$result = $spamassassinScore->getScore($emailContent);
// Access the score
$score = $result['score'] ?? null;
[
'success' => true,
'score' => 2.5,
'rules' => [
// Full list of rules that matched
],
'description' => '...'
]
[
'success' => true,
'score' => 2.5
]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.