Server IP : 127.0.0.2 / Your IP : 3.144.112.72 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/ |
Upload File : |
<?php namespace Illuminate\Mail; use ReflectionClass; use ReflectionProperty; use BadMethodCallException; use Illuminate\Support\Str; use Illuminate\Support\Collection; use Illuminate\Container\Container; use Illuminate\Contracts\Queue\Factory as Queue; use Illuminate\Contracts\Mail\Mailer as MailerContract; use Illuminate\Contracts\Mail\Mailable as MailableContract; class Mailable implements MailableContract { /** * The person the message is from. * * @var array */ public $from = []; /** * The "to" recipients of the message. * * @var array */ public $to = []; /** * The "cc" recipients of the message. * * @var array */ public $cc = []; /** * The "bcc" recipients of the message. * * @var array */ public $bcc = []; /** * The "reply to" recipients of the message. * * @var array */ public $replyTo = []; /** * The subject of the message. * * @var string */ public $subject; /** * The view to use for the message. * * @var string */ public $view; /** * The plain text view to use for the message. * * @var string */ public $textView; /** * The view data for the message. * * @var array */ public $viewData = []; /** * The attachments for the message. * * @var array */ public $attachments = []; /** * The raw attachments for the message. * * @var array */ public $rawAttachments = []; /** * The callbacks for the message. * * @var array */ public $callbacks = []; /** * Send the message using the given mailer. * * @param \Illuminate\Contracts\Mail\Mailer $mailer * @return void */ public function send(MailerContract $mailer) { Container::getInstance()->call([$this, 'build']); $mailer->send($this->buildView(), $this->buildViewData(), function ($message) { $this->buildFrom($message) ->buildRecipients($message) ->buildSubject($message) ->buildAttachments($message) ->runCallbacks($message); }); } /** * Queue the message for sending. * * @param \Illuminate\Contracts\Queue\Factory $queue * @return mixed */ public function queue(Queue $queue) { $connection = property_exists($this, 'connection') ? $this->connection : null; $queueName = property_exists($this, 'queue') ? $this->queue : null; if ($queueName) { return $queue->connection($connection)->pushOn( $queueName, new SendQueuedMailable($this) ); } else { return $queue->connection($connection)->push( new SendQueuedMailable($this) ); } } /** * Deliver the queued message after the given delay. * * @param \DateTime|int $delay * @param Queue $queue * @return mixed */ public function later($delay, Queue $queue) { $connection = property_exists($this, 'connection') ? $this->connection : null; $queueName = property_exists($this, 'queue') ? $this->queue : null; if ($queueName) { return $queue->connection($connection)->laterOn( $queueName, $delay, new SendQueuedMailable($this) ); } else { return $queue->connection($connection)->later( $delay, new SendQueuedMailable($this) ); } } /** * Build the view for the message. * * @return array|string */ protected function buildView() { if (isset($this->view, $this->textView)) { return [$this->view, $this->textView]; } elseif (isset($this->textView)) { return ['text' => $this->textView]; } else { return $this->view; } } /** * Build the view data for the message. * * @return array */ public function buildViewData() { $data = $this->viewData; foreach ((new ReflectionClass($this))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { if ($property->getDeclaringClass()->getName() != self::class) { $data[$property->getName()] = $property->getValue($this); } } return $data; } /** * Add the sender to the message. * * @param \Illuminate\Mail\Message $message * @return $this */ protected function buildFrom($message) { if (! empty($this->from)) { $message->from($this->from[0]['address'], $this->from[0]['name']); } return $this; } /** * Add all of the recipients to the message. * * @param \Illuminate\Mail\Message $message * @return $this */ protected function buildRecipients($message) { foreach (['to', 'cc', 'bcc', 'replyTo'] as $type) { foreach ($this->{$type} as $recipient) { $message->{$type}($recipient['address'], $recipient['name']); } } return $this; } /** * Set the subject for the message. * * @param \Illuminate\Mail\Message $message * @return $this */ protected function buildSubject($message) { if ($this->subject) { $message->subject($this->subject); } else { $message->subject(Str::title(Str::snake(class_basename($this), ' '))); } return $this; } /** * Add all of the attachments to the message. * * @param \Illuminate\Mail\Message $message * @return $this */ protected function buildAttachments($message) { foreach ($this->attachments as $attachment) { $message->attach($attachment['file'], $attachment['options']); } foreach ($this->rawAttachments as $attachment) { $message->attachData( $attachment['data'], $attachment['name'], $attachment['options'] ); } return $this; } /** * Run the callbacks for the message. * * @param \Illuminate\Mail\Message $message * @return $this */ protected function runCallbacks($message) { foreach ($this->callbacks as $callback) { $callback($message->getSwiftMessage()); } return $this; } /** * Set the priority of this message. * * The value is an integer where 1 is the highest priority and 5 is the lowest. * * @param int $level * @return $this */ public function priority($level = 3) { $this->callbacks[] = function ($message) use ($level) { $message->setPriority($level); }; return $this; } /** * Set the sender of the message. * * @param object|array|string $address * @param string|null $name * @return $this */ public function from($address, $name = null) { return $this->setAddress($address, $name, 'from'); } /** * Set the recipients of the message. * * @param object|array|string $address * @param string|null $name * @return $this */ public function to($address, $name = null) { return $this->setAddress($address, $name, 'to'); } /** * Set the recipients of the message. * * @param object|array|string $address * @param string|null $name * @return $this */ public function cc($address, $name = null) { return $this->setAddress($address, $name, 'cc'); } /** * Set the recipients of the message. * * @param object|array|string $address * @param string|null $name * @return $this */ public function bcc($address, $name = null) { return $this->setAddress($address, $name, 'bcc'); } /** * Set the "reply to" address of the message. * * @param object|array|string $address * @param string|null $name * @return $this */ public function replyTo($address, $name = null) { return $this->setAddress($address, $name, 'replyTo'); } /** * Set the recipients of the message. * * @param object|array|string $address * @param string|null $name * @param string $property * @return $this */ protected function setAddress($address, $name = null, $property = 'to') { if (is_object($address) && ! $address instanceof Collection) { $address = [$address]; } if ($address instanceof Collection || is_array($address)) { foreach ($address as $user) { $user = $this->parseUser($user); $this->{$property}($user->email, isset($user->name) ? $user->name : null); } } else { $this->{$property}[] = compact('address', 'name'); } return $this; } /** * Parse the given user into an object. * * @param mixed $user * @return object */ protected function parseUser($user) { if (is_array($user)) { return (object) $user; } elseif (is_string($user)) { return (object) ['email' => $user]; } return $user; } /** * Set the subject of the message. * * @param string $subject * @return $this */ public function subject($subject) { $this->subject = $subject; return $this; } /** * Set the view and view data for the message. * * @param string $view * @param array $data * @return $this */ public function view($view, array $data = []) { $this->view = $view; $this->viewData = $data; return $this; } /** * Set the plain text view for the message. * * @param string $textView * @param array $data * @return $this */ public function text($textView, array $data = []) { $this->textView = $textView; $this->viewData = $data; return $this; } /** * Set the view data for the message. * * @param string|array $key * @param mixed $value * @return $this */ public function with($key, $value = null) { if (is_array($key)) { $this->viewData = array_merge($this->viewData, $key); } else { $this->viewData[$key] = $value; } return $this; } /** * Attach a file to the message. * * @param string $file * @param array $options * @return $this */ public function attach($file, array $options = []) { $this->attachments[] = compact('file', 'options'); return $this; } /** * Attach in-memory data as an attachment. * * @param string $data * @param string $name * @param array $options * @return $this */ public function attachData($data, $name, array $options = []) { $this->rawAttachments[] = compact('data', 'name', 'options'); return $this; } /** * Register a callback to be called with the Swift message instance. * * @param callable $callback * @return $this */ public function withSwiftMessage($callback) { $this->callbacks[] = $callback; return $this; } /** * Dynamically bind parameters to the message. * * @param string $method * @param array $parameters * @return $this * * @throws \BadMethodCallException */ public function __call($method, $parameters) { if (Str::startsWith($method, 'with')) { return $this->with(Str::snake(substr($method, 4)), $parameters[0]); } throw new BadMethodCallException("Method [$method] does not exist on mailable."); } }