Script to send an e-mail with sendmail

Hi people. Let me first introduce myself by saying that I'm a newbie to the FreeBSD, and almost any Unix/Linux too. I've looked anyway in the Handbook and Mailing lists for this. Having done the disclaimer, here's my issue:
I've set up a very modest home server, mainly used for my personal research satisfaction... it does not perform any crital tasks at all.
Ever since I installed it, FreeBSD reboots itself every 3 or 4 days without any warning or error message. I've written a very simple shell script in order to have it send an e-mail to different accounts when the server is restarted. However, I'm not getting those e-mails at all. They are bounced back because my (dinamic) "IP is not trusted". The line which send the mail reads:

$ cat mail.test | mail -s "server reboot notification" -F

I guess this is a just a security feature against spam from GMail, Hotmail, etc, which I can obviously understand. But I cannot find a way to have the mail delivered! I do have a .forward file with my GMail e-mail address, and FreeBSD manges to get send me the daily check output without any issue.
Does anyone know why the e-mails I'm sending manually while running the script fail?
Thanks in advance.
However, I'm not getting those e-mails at all. They are bounced back because my (dinamic) "IP is not trusted".

Each email message is assigned a unique "Message-Id", and your /var/log/maillog file should include lines like:

Dec 12 05:43:26 kobe sm-mta[6151]: mBC3hQLw006151:
  from=<>, size=7765, class=0,
  nrcpts=1, msgid=<>,
  proto=ESMTP, daemon=Daemon0, relay=kobe.laptop []
Dec 12 05:43:26 kobe sm-mta[6152]: mBC3hQLw006151:
  to="|exec /usr/local/bin/procmail || exit 75",
  ctladdr=<keramida@localhost.laptop> (1000/1000),
  delay=00:00:00, xdelay=00:00:00, mailer=prog, pri=37971,
  dsn=2.0.0, stat=Sent

After the process ID at "sm-mta[6151]" and "sm-mta[6152]" there is an easy to locate identifier, mBC3hQLw006151 in this case. Can you grep using this sort of identifier and show us all the log entries for a message that fails?

I think you are trying to send directly to external SMTP servers, without passing through your Internet Service Provider's mail gateway. This won't work, but to be sure that this is indeed the case, we have to see the log file entries.
I've read something like what you mentioned: I should first reach the SMTP server through my ISP's mail gateway. Don't quiet understand what that means anyway...
Here's the log:

Dec 11 21:05:35 hostname sendmail[37382]: mBBN44e0037382:, ctladdr=root (0/0), delay=00:01:31, xdelay=00:01:30, mailer=relay, pri=30091, relay=[] [], dsn=2.0.0, stat
=Sent (mBBN45q5037384 Message accepted for delivery)
Dec 11 21:06:08 hostname sm-mta[37389]: mBBN45q5037384: to=<>, ctladdr=<root@hostname.netname> (0/0), delay=00:00:33, xdelay=00:00:33, mailer=esmtp, pri=30423, relay=gmail-smtp-in.l.googl [], dsn=5.0.0, stat=Service unavailable
Dec 11 21:06:08 hostname sm-mta[37389]: mBBN45q5037384: mBBN68q5037389: DSN: Service unavailable
Dec 11 21:06:40 hostname sm-mta[37389]: mBBN68q5037389:, delay=00:00:32, xdelay=00:00:32, mailer=esmtp, pri=31447, [], dsn=2.0.0, stat=S
ent (OK 1229036812 h27si613187elf.16)
Dec 11 22:14:07 hostname sendmail[37590]: mBC0E6b5037590: from=username, size=126, class=0, nrcpts=1, msgid=<200812120014.mBC0E6b5037590@hostname.netname>, relay=username@localhost
Dec 11 22:15:37 hostname sm-mta[37591]: mBC0E7Jv037591: from=<username@hostname.netname>, size=487, class=0, nrcpts=1, msgid=<200812120014.mBC0E6b5037590@hostname.netname>, proto=ESMTP, daemon=Daemon0, rela
y=localhost []
Dec 11 22:15:37 hostname sendmail[37590]: mBC0E6b5037590:, ctladdr=username (1001/1001), delay=00:01:31, xdelay=00:01:30, mailer=relay, pri=30126, relay=[] [], d
sn=2.0.0, stat=Sent (mBC0E7Jv037591 Message accepted for delivery)
Dec 11 22:16:10 hostname sm-mta[37596]: mBC0E7Jv037591: to=<>, ctladdr=<username@hostname.netname> (1001/1001), delay=00:00:33, xdelay=00:00:33, mailer=esmtp, pri=30487, relay=gmail-s [], dsn=5.0.0, stat=Service unavailable
Dec 11 22:16:10 hostname sm-mta[37596]: mBC0E7Jv037591: mBC0GAJv037596: DSN: Service unavailable
Dec 11 22:16:10 hostname sm-mta[37596]: mBC0GAJv037596: to=<username@hostname.netname>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31511, relay=local, dsn=2.0.0, stat=Sent
Dec 12 00:00:00 hostname newsyslog[37809]: logfile turned over

For obvious reasons, I've replaced:
* my e-mail address by
* server's name by hostname
* domain name by netname
It looks like your local Sendmail process tries to deliver *directly* to one of Google's mail servers. If you have a dynamic IP address this is very likely to fail (most sites now block dynamic IP address ranges, to avoid getting spammed).

You have to find out the hostname of your ISP's mail gateway, and then modify your "/etc/mail/" file (where "HOSTNAME" is the host name of your local machine) to enable the following option:

dnl Dialup users should uncomment and define this appropriately
define(`SMART_HOST', `your.isp.mail.server')

Replace your.isp.mail.server with the hostname of the mail gateway your ISP uses (note that there are two types of quote characters in that line; make sure you use the right type of opening and closing quote), save the file, and then run as root:

# cd /etc/mail
# make all && make restart

If you don't know the right hostname for the mail gateway of your ISP, you will have to ask them. It is commonly something like "", "" or "", but it doesn't hurt to ask.