clrghouz/app/Traits/MessagePath.php

47 lines
1.2 KiB
PHP
Raw Normal View History

<?php
/**
* Add show the message detail
*/
namespace App\Traits;
use App\Models\{Echomail,Netmail};
trait MessagePath
{
protected function message_path(Echomail|Netmail $mo): string
{
$reply = "This is your original message:\r\r";
$reply .= "+--[ BEGIN MESSAGE ]----------------------------------+\r";
$reply .= sprintf("TO: %s\r",$mo->to);
$reply .= sprintf("SUBJECT: %s\r",$mo->subject);
$reply .= str_replace("\r---","\r#--",$mo->msg)."\r";
$reply .= "+--[ CONTROL LINES ]----------------------------------+\r";
$reply .= sprintf("DATE: %s\r",$mo->date->format('Y-m-d H:i:s'));
$reply .= sprintf("MSGID: %s\r",$mo->msgid);
foreach ($mo->kludges as $k=>$v)
$reply .= sprintf("%s %s\r",$k,$v);
$reply .= "+--[ PATH ]-------------------------------------------+\r";
if ($mo->path->count())
if ($mo instanceof Netmail) {
foreach ($mo->path as $o)
$reply .= sprintf("VIA: %s\r",$mo->via($o));
} else {
foreach ($mo->path as $o)
$reply .= sprintf("VIA: %s\r",$o->ftn);
}
else
$reply .= "No path information? This would be normal if this message came directly to the hub\r";
2023-09-21 05:25:18 +00:00
$reply .= "+--[ END MESSAGE ]------------------------------------+\r\r";
return $reply;
}
}