Linux – How to send email with the CentOS server

centosemaillinuxsendmail

I just built a modest home server using CentOS 5.5. I want the server to be able to send emails to my Gmail account or other email accounts for various things like cron jobs. Also it would be nice to be able to send email via PHP applications that I run/develop on the server as well. Or even be able for the server to send emails via the mail command.

I know there are a million Google search results about setting up your Linux server as an email server or configuring sendmail etc. But they don't seem to be what I'm looking for… at least I don't think so. I'm not trying to setup some corporate server that other clients can connect to send out emails or anything complicated like that.

I just want my server to send me emails about stuff. Seems like it should be simple… Can anyone point me in the right direction?

UPDATE

Per a users request below, I tried this command:

/bin/mail -s "My Subject" "myaddress@gmail.com" < /home/john/test

No errors or anything. But the email never showed up in my inbox. Here is my maillog

Oct 27 00:52:19 localhost sendmail[13702]: o9R6qJhU013702: from=root, size=10906, class=0, nrcpts=1, msgid=<201010270652.o9R6qJhU013702@localhost.localdomain>, relay=root@localhost
Oct 27 00:52:19 localhost sendmail[13703]: o9R6qJOd013703: from=<root@localhost.localdomain>, size=11209, class=0, nrcpts=1, msgid=<201010270652.o9R6qJhU013702@localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Oct 27 00:52:19 localhost sendmail[13702]: o9R6qJhU013702: to=myaddress@gmail.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=40906, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o9R6qJOd013703 Message accepted for delivery)

Any clues?

Best Answer

/bin/mail -s "Enter Subject Line here" -a /home/.../whateverFileYouWantAttached "you@YourEmailAddress" < /home/me/textBody.letter

try above command :)

Related Topic