Here is my email send php file , email sent but attachment is not working. File is there on that path . Issue is I need to get file name from a linux command and store in a variable . When I called that variable attachment is not working. 

```
<?php

require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$file_name1 = shell_exec('sed "1q;d" /tmp/file.txt');
$file = "/home/user/.$file_name1";
echo $file;

//set Address data
$mail->Subject = "Acknowledgement Files ".date("m-d-Y:h:i:s")." ";
$mail->MsgHTML(" Acknowledgement Files are here attached");
$mail->AddAttachment($file)

if($mail->Send()) {
        echo "Message sent!";
} else {
        echo "Mailer Error: " . $mail->ErrorInfo;
}

?>

```

If I am going to use full path like 

`$file = "/home/user/filetxt"`

this works but I want to call variable and echo is display correct name.
any thoughts?