Remove unused vars in email template API.
Fixed undefined/no index errors.

fixes gh-311