Mailgun\Messages\MessageBuilder::addAttachment PHP Method

addAttachment() public method

public addAttachment ( string $attachmentPath, string | null $attachmentName = null ) : boolean
$attachmentPath string
$attachmentName string | null
return boolean
    public function addAttachment($attachmentPath, $attachmentName = null)
    {
        if (isset($this->files['attachment'])) {
            $attachment = ['filePath' => $attachmentPath, 'remoteName' => $attachmentName];
            array_push($this->files['attachment'], $attachment);
        } else {
            $this->files['attachment'] = [['filePath' => $attachmentPath, 'remoteName' => $attachmentName]];
        }
        return true;
    }

Usage Example

示例#1
0
 /**
  * Attach a file to the message.
  *
  * @param string $path
  * @param string $name
  *
  * @return \Bogardo\Mailgun\Mail\Message
  */
 public function attach($path, $name = '')
 {
     $this->messageBuilder->addAttachment($path, $name);
     return $this;
 }
All Usage Examples Of Mailgun\Messages\MessageBuilder::addAttachment