How to send e-mail from Ubuntu server?

It does not make perfect sense because you have said, "supposed to do," as though it is your job. Are you setting up a real mail server within a virtual machine? I take the clues to mean that you need the virtual server to have a mail system, but that the virtual server is not a full-time "real" SMTP server. (Otherwise you would know already, I guess wildly.)

With that in mind, you would need the "Internet with smarthost" option. Essentially, the big reason is that well-configured SMTP servers around the world all use anti-spam measures; and, among these measures is the rejection of all SMTP connections that come from known pools of dynamic addresses (that spammers love to use). Therefore, you need to use another SMTP server for outgoing mail.

If you want to stick with Postfix for this, it is easy to do: just search for Ubuntu articles related to setting up Postfix as a smarthost. However, if you have no particular affinity for one system over another, there is a package designed just for this: ssmtp. So, if you want to give it a spin, then just install ssmtp.

(Caution: the action below will remove postfix or sendmail.)

sudo apt-get install ssmtp

Then edit the ssmtp configuration file:

sudo -e /etc/ssmtp/ssmtp.conf

I do not know details of an SMTP server available to you, so I will give a GMail example:

[email protected]
Mailhub=smtp.gmail.com:465
RewriteDomain=gmail.com
AuthUser=your_gmail_username # [email protected]
AuthPass=your_gmail_password
FromLineOverride=Yes
UseTLS=Yes

Now your system will send mail the way you want. You can use localhost as a mail server in your GUI applications for the outgoing SMTP server. But what about the CLI? Use the mail software:

sudo apt-get install heirloom-mailx

Now you can also use mail from the command line with something like:

mail < filename.ascii [email protected] -s "My File"

Or, if you use mail to compose a message you type (mail [email protected]), then finish off the mail message with a single period on a blank line. A better CLI mail client is mutt or pine.

Is this the angle you needed? If so, was it successful?