Sendmail, SMTP, Gmail relay on Fedora 14

I need to send SMTP email out from my home box running Fedora 14, so I can try StatusNet (Laconica microblog). These days email cannot be sent directly out from a residential DSL because it looks like spam. My ISP provides no SMTP relay, but I can use Gmail—thank you, Google. Fedora 14 comes with sendmail, but it is harder to configure than most Linux software. So now here is what I cobbled together from two sites: AppGirl: “Configuring Sendmail to relay through Gmail SMTP” and James Lloyd: “Using Gmail as a Sendmail Relay”. First, open a terminal and run:

su - # login as root
yum -y install sendmail-cf # install sendmail
cp /etc/mail/ /etc/mail/ # make a backup
vi /etc/mail/ # edit configuration

Near the very bottom before MAILER insert the following lines. Sendmail is picky about the quotation marks: when I first pasted them, they were wrong and gave me a syntax error. This section is a combination of the two sources above which fixes the error in /var/log/maillog “no route to host” which apparently has nothing to do with DNS resolution.

define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl

Then save. Back in the terminal:

mkdir /etc/mail/auth # a place to store credentials
vi /etc/mail/auth/client-info # edit credentials file "U:root" "I:<YOUR GMAIL USERNAME HERE>" "P:<YOU GMAIL PASSWORD HERE>"

Of course, fill out your real login info, save, and exit. The next section skips the part about the openssl certificates: I ran it, but it didn’t seen to be necessary on Fedora.

makemap hash client-info < client-info
chmod 700 /etc/mail/auth
chmod 600 /etc/mail/auth/*
cd /etc/mail
make # compile configuration
service sendmail restart # read new configuration

Finally, send a test email.

echo 'this is a test'| mail -s test_email

If it fails, read /var/log/maillog and /var/log/messages.


18 thoughts on “Sendmail, SMTP, Gmail relay on Fedora 14

  1. Pingback: Install Status.Net testing from Git on Fedora « Heuristic Andrew

  2. Superb…took hardly 5 minutes to set up and sending mail is fine now. How do I test receiving part? Appreciate any suggestions …

    • POP3 and IMAP are common ways to receive email while avoiding the hassle of setting up a public SMTP server, which would mean dealing with spam.

  3. “[root@gaurav mail]# make Warning: excess arguments to builtin `define’ ignored cannot open `/usr/share/sendmail-cf/feature/’authinfo’.m4′: No such file or directory”
    Why di I am getting these errors ,please help me

    • I do not get this error when issuing “make”; however, I do get it when issuing: “make -C /etc/mail”

      I can send test mails but they are sent from the server (i.e., not from the relay account at gmail).

      Please, did you find a solution to this error?

      • As it turns out the issue was addressed in the article body: “…Sendmail is picky about the quotation marks…” So the error is produced when you edit them. If the code is copied and pasted as is then the error goes away.

  4. Many thanks!! Just a couple comments:
    1. Once the hashed client-info file (called client-info.db) has been created, you should delete the original client-info file. This protects your smtp user name and password.
    2. My sendmail version doesn’t support the -s command line option. In fact, I can’t seem to find a sendmail option that sets the email’s “Subject” field.
    3. When attempting to run the test, I had to replace the command “mail” with “sendmail” . For whatever reason, perhaps a missing syslink mapping, specifying mail resulted in Fedora 14 asking me if I wanted to install a mail package.

  5. I’m getting mails from my server, not from my relay host. Why would that occur? My goal is to shut down all mail operations on the server aside from sending message via relay over gmail.

    • This was partly resolved (see earlier reply comment above). The previous mails were from localhost while new mails are sent via relay account. The problem still remaining, however, is how to shut down all non-relay mails from server and to disable all incoming mail requests. Anybody?

    • That command tries to execute /var/spool/mail/root which is not an executable. I think that file contains root’s email. You can view it like this

      less /var/spool/mail/root

  6. Hello every body:
    all steps are fine but i am getting an error while using this command
    {service sendmail restart}
    it says
    bash : service : command not found …
    install package ‘initscript’ to peovide command ‘service’
    i have installed this package but always face the above message

    Please send possible solution

  7. Pingback: Snapshot Backup using DNS-321, Review and HOWTO - Coert Vonk

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s