switch to use of $CFG->tempdir
prevent receiver address from containing whitespace at beginning or end.