My guess is you need to be sure the outgoing server is set to the correct name. For gmail, for example, you need to change the settings within gmail to enable IMAP, and then set the outgoing server within Mail to smtp.gmail.com:username
In general the outgoing mail server will be your email server preceded by "smtp."