Search code examples
phpphpmailersender

Making my sender option to send attachment or not


Anybody have idea what happen with my sender? , trying to make an option to send attachment or not

if ($makassarid_setup['filesend'] == 1) {
$filepdf = file_get_contents($AddAttachment);
$mail->AddAttachment($filepdf);
}

Thats are from the MKSENDERS , the sender its self the $makassarid_setup came from the mks.setting.php as the config file, its have been included as the top of MKSENDERS file as u see on if ($makassarid_setup['filesend'] == 1) { it should be sending attachment if i have set 1 on the mks.setting.php file "filesend" => 1, (on mks.setting.php) , but it given me output when im execute the sender

PHP Notice:  Undefined variable: AddAttachment in /home/ubuntu/workspace/DEATHhomo/MKSENDERS on line 125
PHP Warning:  file_get_contents(): Filename cannot be empty in /home/ubuntu/workspace/DEATHhomo/MKSENDERS on line 125.

when im turn the "filesend" => 0, it send the email normally, without any error input, and the $filepdf is came from the mks.setting.php "filepdf" => "file/attachment/a.pdf", so it the filename not empty ofcourse, i would really appreciate any help from you.

Thanks Alot! :D


Solution

  • PHPMailer just needs the filename, not its contents, so it seems you want:

    if($makassarid_setup['filesend']==1){
        $mail->AddAttachment($filepdf);
    }