Back | Home
الـ Path الحالي: /home/picotech/domains/instantly.picotech.app/public_html/public/uploads/./../../app/EmailProvider
الملفات الموجودة في هذا الـ Path:
.
..
AmazonSmtp.php
ElasticApi.php
ElasticSmtp.php
MailGunApi.php
MailGunSmtp.php
SendEMail.php
SendGridApi.php
SendMailInterface.php
SendMailProcess.php
Sendmail.php
Smtp.php
SparkpostSmtp.php

مشاهدة ملف: SendMailProcess.php

<?php

namespace App\EmailProvider;

use App\Models\Campaign;
use Illuminate\Support\Facades\Log;

class SendMailProcess
{

    private $provider;
    public $to;
    public $from;
    public $file;
    public $subject;
    public $body;
    public $message;
    public $config;
    private $errors;
    private $server_config_value;


    public function __construct()
    {
        $this->server_config_value=collect([]);
        $this->errors=[];
    }
    public function getErrors(){
        return $this->errors;
    }
    public function hasErrors(){
        return count($this->errors)>0;
    }
    public function serverConfig($config)
    {
        $this->server_config_value = $config[$this->provider];
        return $this;
    }

    public function setMessage($message)
    {
        $this->message = $message;
        return $this;
    }

    public function setProvider($provider)
    {
        $this->provider = $provider;
        return $this;
    }

    public function getTo()
    {
        return isset($this->message) ? $this->message->to : null;
    }

    public function getFrom()
    {
        if(isset($this->server_config_value->send_dkim_private_key) && $this->server_config_value->send_dkim_private_key){
            return isset($this->message) ? $this->message->from : null;
        }else{
            return $this->server_config_value->from_email;
        }

    }

    public function getFromName()
    {
        return isset($this->message) ? ($this->message->from_name?:getNameFromEmail($this->getFrom())) : null;
    }

    public function getReplyTo()
    {
        if(isset($this->server_config_value->send_dkim_private_key) && $this->server_config_value->send_dkim_private_key){
            return isset($this->message) ? $this->message->reply_to : null;
        }else{
            return $this->server_config_value->from_email;
        }
    }

    public function getSubject()
    {
        return isset($this->message) ? $this->message->subject : null;
    }

    public function getBody()
    {
        $body = $this->message->body;
        if (!$this->message->body) {
            $body = replaceMessageBody($this->message->body, $this->message->campaign_id, $this->message->id, $this->message->template);
        }
        return $body;
    }

    public function getFiles()
    {
        return isset($this->message) ? $this->message->message_files : null;
    }

    public function process()
    {
        \App\Events\SendEMail::dispatch(
            $this->provider,
            $this->getFrom(),
            $this->getFromName(),
            $this->getTo(),
            $this->getSubject(),
            $this->getBody(),
            $this->getReplyTo(),
            $this->getFiles(),
            $this->server_config_value,
            $this->message->id //email_queues id
        );
        return $this;

    }

}