Subscribe via

Setting up Sendmail on FreeBSD 6.2

Previously, I mentioned that I was not able to successfully send emails via sendmail. This functionality is quite useful because WordPress, among other things, uses sendmail to send emails to you when someone leaves a comment on your post. So it turns out that because most public mail servers (i.e. gmail, hotmail, etc) do not trust my “omninoggin.com” mail server domain, all messages I sent were refused. After hours of research, I found out that I can route my mail traffic through my internet service provider’s mail proxy (SBC Yahoo!) to get this to work.

I started by following the Open Addict tutorial section “Configuring Mail Services”. After the step “Edit the [hostname].mc file, add these lines, I put mine above DAEMON_OPTIONS,” I stopped following the tutorial and did the following:

  1. Add these lines into my [hostname].mc file (above DAEMON_OPTIONS). Also note that “smtp.sbc.mail.yahoo4.akadns.net” is SBC Yahoo’s mail proxy server.
    define(`confAUTH_OPTIONS', `A')dnl
    define(`confAUTH_MECHANISMS', `PLAIN LOGIN')dnl
    TRUST_AUTH_MECH(`PLAIN LOGIN')dnl
    FEATURE(`authinfo',`hash /etc/mail/authinfo')dnl
    define(`SMART_HOST',`smtp.sbc.mail.yahoo4.akadns.net')dnl
  2. Create the file /etc/mail/authinfo and put the following into it (all in one line) and save (also make sure you replace <your-username> and <your-password> with your real username and password):
    AuthInfo:smtp.sbc.mail.yahoo4.akadns.net
    "U:<your-username>@sbcglobal.net"
    "I:<your-username>@sbcglobal.net"
    "R:sbcglobal.net" "P:<your-password>" "M:PLAIN"
  3. Run the following command:
    makemap hash /etc/mail/authinfo < /etc/mail/authinfo
  4. Set sendmail to start (and listen) at boot, so add this to /etc/rc.conf:
    sendmail_enable="YES"
  5. Create the file /etc/mail/local-host-names and insert your domain name(s) to accept mail for. Then, finish the sendmail re-build.
    touch /etc/mail/local-host-names
    make all install restart
  6. Send a test email to yourself
    sendmail -f "webmaster@your-domain.com" -F "webmaster"
    From: Webmaster <webmaster@your-domain.com>
    To: your.other@email.com
    Subject: Hello World!
    Hello World!
    .

This should work but in case it doesn’t, there is some good troubleshooting information on DSL Reports. It took me 5 hours to figure this out so good luck!

Save and Share
StumbleUpon
Reddit

7 Responses to “Setting up Sendmail on FreeBSD 6.2”

[go to last comment]
  1. Setting up a FreeBSD 6.2 Web Server: Apache, MySQL, etc (Part 2) | OMNINOGGIN

    [...] *Update* – 10/10/2007 I was able to successfully setup sendmail and wrote a quick guide about it, Setting up Sendmail on FreeBSD 6.2. [...]

  2. tanakskool

    Pity me. I don’t have sbcglobal email account. Any other way to use sendmail? thanks.

  3. Thaya Kareeson

    There is no pity in not having sbcglobal. I’m sure your internet service provider has an outward facing email server that you can piggyback off of. What is your provider? Maybe it might help to search your provider’s name with ‘sendmail’ in google.

  4. tanakskool

    Nvm.. After 6 hours bleeding my brain I finally be able to receive and send email using gmail.. haha.. Thanks for the tutorial anyway, it helped me a bit.. I hope you can make more freebsd tutorial in the future.. thanks again :)

  5. Thaya Kareeson

    You’re welcome (although I didn’t do much)! It seems like 5-6 hours is the common “bleeding my brain out” period for setting up sendmail. Please let me know if you ever create a tutorial about the problems you’ve encountered and how you solved those problems. It would be an interesting read and I wouldn’t mind adding your link as a reference on this article.

  6. tanakskool

    Someone has wrote about it. Here is the link.
    http://www.linuxha.com/other/sendmail/gmail.html

    It’s been a long day and now I’m having another problem. When I send an email, the Sender’s information name always being displayed as from “me” instead to display my own name/username. Also, the Sender’s email address displayed incorrect email. Do you know how to solve this? Thanks

  7. Thaya Kareeson

    Thanks for the link! I didn’t know that you can use gmail as an email proxy. It’s a great alternative for non-SBC folks.

    The “me” problem sounds like a gmail issue.

    If you are sending an email from yourself@gmail.com to yourself@gmail.com, gmail will automatically replace the “from” field with “me”. Are you sending the email to the same address as your email proxy account?

    What could also be happening internally is you might be sending the email to yourself and then gmail forwards that email to your recipient.

    Unfortunately, I do not know how to fix this problem since I do not use gmail as my mail proxy.

    Please let me know when/how you’ve resolved it.

[go to first comment]