Improvements to working out region for new addresses, Bounce netmails to a invalid address (that we would host)
This commit is contained in:
65
app/Notifications/Netmails/NetmailNoDestination.php
Normal file
65
app/Notifications/Netmails/NetmailNoDestination.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Netmails;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Notifications\Netmails;
|
||||
use App\Models\Netmail;
|
||||
use App\Traits\{MessagePath,PageTemplate};
|
||||
|
||||
class NetmailNoDestination extends Netmails
|
||||
{
|
||||
use MessagePath,PageTemplate;
|
||||
|
||||
private const LOGKEY = 'NND';
|
||||
|
||||
private Netmail $mo;
|
||||
|
||||
/**
|
||||
* Send a sysop a message if they give us a message with a bad address in it.
|
||||
*
|
||||
* @param Netmail $mo
|
||||
*/
|
||||
public function __construct(Netmail $mo)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->mo = $mo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return Netmail
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function toNetmail(object $notifiable): Netmail
|
||||
{
|
||||
$o = $this->setupNetmail($notifiable);
|
||||
$ao = $notifiable->routeNotificationFor(static::via);
|
||||
|
||||
Log::info(sprintf('%s:+ Creating NETMAIL NO DESTINATION netmail to [%s]',self::LOGKEY,$ao->ftn));
|
||||
|
||||
$o->subject = sprintf('Bad destination for netmail [%s]',$this->mo->msgid);
|
||||
|
||||
// Message
|
||||
$msg = $this->page(FALSE,'nodest');
|
||||
|
||||
$msg->addText($this->sourceSummary($this->mo)."\r\r");
|
||||
|
||||
$msg->addText(sprintf("The TO address [%s] in this netmail doesnt exist for the domain [%s].\r\r",$this->mo->get_tftn,$ao->zone->domain->name));
|
||||
|
||||
$msg->addText("This netmail has been rejected and not stored here - so no downstream node will receive it. If you think this is a mistake, please let me know.\r\r");
|
||||
|
||||
$msg->addText($this->message_path($this->mo));
|
||||
|
||||
$o->msg = $msg->render();
|
||||
$o->set_tagline = 'I enjoyed reading your message, even though nobody else will get it :)';
|
||||
|
||||
$o->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user