A bit of googlage has informed me that the .cshrc file (located in the account home directory) is used to set environment variables. The .cshrc file is read when a user logs into a shell but I'm trying to set the vars that are read by the daemon that sends emails from a php page. I don't know which .cshrc file I need to edit to add a value for the QMAILUSER variable.
qmail-inject (thus, qmail's sendmail wrapper as well) only looks at the environment to determine the mail sender. It checks the QMAILUSER, MAILUSER, USER and LOGNAME variables in that order until it finds a match. If qmail-inject finds no match, it puts "anonymous" as the sender. Your daemon program however will not have USER and LOGNAME set in the environment, because these are set by the login program -- that is not used by your daemon. qmail-inject does not look at getuid() and getpwuid(), which it should.