Include the last error if available when sending with mail() fails.

When sending email using mail() include the last error if available.

Fixes #2910