How can error handling be improved when using @mysql_query() to send emails in PHP scripts?

When using @mysql_query() to send emails in PHP scripts, error handling can be improved by checking the return value of the function for errors and handling them appropriately. This can be done by checking if the query was successful or not, and if not, displaying an error message or logging the error for further investigation.

$query = @mysql_query("INSERT INTO emails (email) VALUES ('example@email.com')");

if(!$query) {
    echo "Error sending email: " . mysql_error();
    // Log the error for further investigation
} else {
    echo "Email sent successfully!";
}