If you can receive iCloud mail but cannot send mail, then the IMAP settings are correct — this is the path you receive mail from the mail server — and the SMTP server configuration — this is how your mail client sends messages to the mail server — is incorrect.
Details on the setup vary by OS X version. Apple has iCloud setup documentation for OS X 10.7.4 and later, and iCloud documentation for earlier versions and when you're manually setting up IMAP and SMTP.
To get to the SMTP server settings in Mail.app, select the account in Preferences > Accounts, and use the Outgoing Mail Server (SMTP) selector to chose Edit SMTP Server List..., and from there select the particular SMTP server you're setting up (you can have multiple SMTP servers when you have multiple accounts), and make the changes to the settings to match what Apple has documented for iCloud for your version.