fixes/improvements for sending invite emails. backported from nfftt