You are piping with a "|" and redirecting input from a file with a "<" at the same time... Your 'sendmail' program can't get its input from 2 sources.
A pipe should be enough, like in the following example:
base64 $filename | sendmail -i email@example.com
More generally, a pipe is used when you want the output of one program to go in as input to the second program, and input redirection from files (with "<") only works when you have a real file on the disk with the pre-made input for the program.