dolibarr 25.0.0-alpha
emailsignature.lib.php File Reference

Library to evaluate the quality of a user HTML email signature against emailing best practices. More...

Go to the source code of this file.

Functions

 dolCheckSignatureQuality ($html)
 Analyze an HTML email signature and return a quality score (0..100) against common emailing best practices: enough real text vs images, a reasonable number of images, alt text, absolute https URLs, no script/style, contact details present, no oversized fixed widths.
 
 dolGetSignatureQualityBadge ($html, $outputlangs=null)
 Build a ready to print HTML badge summarising the quality of an email signature, with a collapsible list of the best practices that are not met.
 

Detailed Description

Library to evaluate the quality of a user HTML email signature against emailing best practices.

Definition in file emailsignature.lib.php.

Function Documentation

◆ dolCheckSignatureQuality()

dolCheckSignatureQuality ( $html)

Analyze an HTML email signature and return a quality score (0..100) against common emailing best practices: enough real text vs images, a reasonable number of images, alt text, absolute https URLs, no script/style, contact details present, no oversized fixed widths.

Thresholds can be tuned with the constants SIGNATURE_QUALITY_MAX_IMG, SIGNATURE_QUALITY_MAX_IMG_WIDTH, SIGNATURE_QUALITY_MAX_TEXT_LEN, SIGNATURE_QUALITY_MAX_LINKS and SIGNATURE_QUALITY_MIN_CHARS_PER_IMG.

Parameters
string$htmlRaw HTML content of the signature
Returns
array{score:int,grade:string,checks:array<string,array{status:string,weight:int}>} score: 0..100, grade: excellent|good|fair|poor, checks: one entry per rule with status ok|warning|error and the applied penalty

Definition at line 39 of file emailsignature.lib.php.

References dol_string_nohtmltag(), and getDolGlobalInt().

Referenced by dolGetSignatureQualityBadge().

◆ dolGetSignatureQualityBadge()

dolGetSignatureQualityBadge ( $html,
$outputlangs = null )

Build a ready to print HTML badge summarising the quality of an email signature, with a collapsible list of the best practices that are not met.

Parameters
string$htmlRaw HTML content of the signature
?Translate$outputlangsLanguage object for output (defaults to global $langs)
Returns
string HTML snippet, empty string if the signature is empty

Definition at line 242 of file emailsignature.lib.php.

References dol_escape_htmltag(), and dolCheckSignatureQuality().