Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Mail\Application\Contract;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use App\Modules\Mail\Domain\Model\ClientMailbox;
12use App\Modules\Mail\Domain\Model\MailQueueItem;
13use App\Modules\Mail\Domain\Model\MailServer;
14use App\Modules\Mail\Domain\Model\MailSmtp;
15
16/**
17 * Mail Delivery & Queue Dispatching Service Contract.
18 *
19 * @package App\Modules\Mail\Application\Contract
20 */
21interface MailSenderServiceInterface
22{
23    /**
24     * Enqueues an email for asynchronous delivery from a template.
25     *
26     * @param string                $templateCode   Template identifier code.
27     * @param string                $recipientEmail Target recipient email.
28     * @param string|null           $recipientName  Optional recipient name.
29     * @param array<string, scalar> $params         Replacement parameters map.
30     * @param string                $priority       Delivery priority (urgent, high, normal).
31     * @param string                $languageCode   Preferred language code.
32     * @return int Enqueued queue record ID.
33     */
34    public function enqueueFromTemplate(
35        string $templateCode,
36        string $recipientEmail,
37        ?string $recipientName = null,
38        array $params = [],
39        string $priority = 'normal',
40        string $languageCode = 'en'
41    ): int;
42
43    /**
44     * Directly delivers an email item via SMTP transport.
45     *
46     * @param MailQueueItem $item Queue record item.
47     * @param MailSmtp      $smtp SMTP configuration.
48     * @return bool True on successful transmission.
49     */
50    public function sendQueueItem(MailQueueItem $item, MailSmtp $smtp): bool;
51
52    /**
53     * Tests live connectivity and credentials for an SMTP configuration.
54     *
55     * @param MailSmtp $smtp          SMTP configuration instance.
56     * @param string   $testRecipient Target test recipient address.
57     * @return array{success: bool, message: string} Result descriptor.
58     */
59    public function testConnection(MailSmtp $smtp, string $testRecipient): array;
60
61    /**
62     * Tests socket connectivity to IMAP and SMTP ports of a mail server.
63     *
64     * @param MailServer $server Mail server configuration.
65     * @return array{success: bool, message: string} Result descriptor.
66     */
67    public function testMailServerConnection(MailServer $server): array;
68
69    /**
70     * Tests live connectivity for a client mailbox.
71     *
72     * @param ClientMailbox $mailbox Mailbox model instance.
73     * @param MailServer    $server  Mail server model instance.
74     * @return array{success: bool, message: string} Result descriptor.
75     */
76    public function testMailboxConnection(ClientMailbox $mailbox, MailServer $server): array;
77}