Skip to main content
Version: Fegg 5.x (next)

Mail::pushAttached

Add attachment file

Description​

public self Mail::pushAttached( string $filePath, [ string $fileName = null ] )

Nothing is added when $filePath does not exist. Attachments are sent with Mail::send.

Arguments​

NameData typeDefaultRemarks
$filePathstringAttachment file path
$fileNamestringnullFile name shown in the email / if omitted, the base name of $filePath

Example​

Controller
use Fegg\Tool\Mail;

$mail = new Mail('Mail subject', 'Mail body');
$mail->pushAttached('path/to/file.pdf', 'document.pdf');
$mail->send('mail@example.com', 'John Doe', 'from@example.com');