[Ubuntu 14.04 LAMP] Installed sendmail -- fatal error when I sent first message

November 13, 2015 1.4k views
Email Linux Basics Ubuntu

OS: Ubuntu 14.04
Stack: LAMP


I followed Jonathan's instructions from from this post.

I created a test email and saved it at /tmp/email.txt

I tried to send a test email from a text file to my Yahoo email account using this command:

sendmail roypenrod123@yahoo.com  < /tmp/email.txt

The process completed.

When I logged back in, it said I had mail.

I installed mailutils to read the mail. It was a returned message saying sendmail couldn't send the message and it mentioned a fatal error.

Here is the complete message:

From MAILER-DAEMON  Fri Nov 13 11:22:34 2015
Return-Path: <MAILER-DAEMON>
Received: from localhost (localhost)
    by roypenroddotcom (8.14.4/8.14.4/Debian-4.1ubuntu1) id tADGMYu6005485;
    Fri, 13 Nov 2015 11:22:34 -0500
Date: Fri, 13 Nov 2015 11:22:34 -0500
From: Mail Delivery Subsystem <MAILER-DAEMON>
Message-Id: <201511131622.tADGMYu6005485@roypenroddotcom>
To: <roy@roypenroddotcom>
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)

This is a MIME-encapsulated message


The original message was received at Fri, 13 Nov 2015 11:22:33 -0500
from localhost []

   ----- The following addresses had permanent fatal errors -----
    (reason: 501 Syntax error in parameters or arguments)

   ----- Transcript of session follows -----
... while talking to mta7.am0.yahoodns.net.:
>>> MAIL From:<roy@roypenroddotcom> SIZE=637
<<< 501 Syntax error in parameters or arguments
501 5.6.0 Data format error

Content-Type: message/delivery-status

Reporting-MTA: dns; roypenroddotcom
Received-From-MTA: DNS; localhost
Arrival-Date: Fri, 13 Nov 2015 11:22:33 -0500

Final-Recipient: RFC822; roypenrod123@yahoo.com
Action: failed
Status: 5.5.2
Diagnostic-Code: SMTP; 501 Syntax error in parameters or arguments
Last-Attempt-Date: Fri, 13 Nov 2015 11:22:34 -0500

Content-Type: text/rfc822-headers

Return-Path: <roy@roypenroddotcom>
Received: from roypenroddotcom (localhost [])
    by roypenroddotcom (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id tADGMXu6005483
    for <roypenrod123@yahoo.com>; Fri, 13 Nov 2015 11:22:33 -0500
Received: (from roy@localhost)
    by roypenroddotcom (8.14.4/8.14.4/Submit) id tADGMXlU005480
    for roypenrod123@yahoo.com; Fri, 13 Nov 2015 11:22:33 -0500
Date: Fri, 13 Nov 2015 11:22:33 -0500
From: Roy Penrod <roy@roypenroddotcom>
Message-Id: <201511131622.tADGMXlU005480@roypenroddotcom>
Subject: Terminal Email Send


Problem 1:

I noticed the return-path is roy@roypenroddotcom. I named my host roypenroddotcom because it's hosting my own personal site, roypenrod.com.

I'm very new to Linux, so I didn't know the hostname would affect this. How do I change it so my email address is actually roy@roypenrod.com?

Problem 2:

Why did the sendmail fail? Was it the incorrect email address? Did I set something up wrong? Do I need to configure sendmail?

Any help you can give me is very much appreciated.


1 comment
  • The error you're seeing is definitely due to the sender's email address not being a resolvable address. To change the Sendmail hostname, use this command:

    define(`confDOMAIN_NAME', `mail.yourdomain.com')dal

    with the mail.yourdomain.com part replaced by roypenrod.com

3 Answers


For completeness, I would setup your DNS as I outlined in our previous discussion, though first, I would login as root and run the following:


This will tell you what your servers hostname is set as right now (which should match roypenroddotcom if that's what you named it when deploying the Droplet).

Now think of a short name for your server. It could be something like web01, core01, node01, droplet01 etc (it doesn't have to contain a number, web works too). This will be your "new" server name and to it, you'll append your domain name like so (I'll use web in this example):


Now run:

hostname web.roypenrod.com

This will change your hostname from roypenroddotcom to web.roypenrod.com. At this point, we need to make sure the DNS can validate this hostname, so we have two primary options.

  • Create a WildCard DNS Entry
  • Create an A Entry Exclusively for web.roypenrod.com

The DNS entries would look like:


A       *       DROPLET_PUBLIC_IP

Exclusive A Entry

A       web     DROPLET_PUBLIC_IP

My personal preference is WildCard since it takes care of pretty much everything for you, reduces the # of 404 errors in the long run (since it forces everything to resolve to your hostname or domain).

When I said it didn't matter which step you took first, I failed to dive deeper in to DNS and for that I apologize. While what I said is indeed true, making sure your DNS is correct is very important. When it comes to e-mail, basically all DNS needs to resolve. If the receiving servers are unable to resolve your domain, the server or other areas of your DNS, they'll reject it or worse, mark it as SPAM or blacklist (thus none of your e-mail will go through).


That being said, from the previous conversation, I was under the impression you were simply looking to use PHP's mail() function to send mail through PHP, not for handling actual e-mail address creation, local delivery etc.

When it comes to setting up an e-mail server, such as one that will allow you to create multiple e-mail accounts using your domain, or any number of domains you choose to host on the server, things are a little more in-depth and complicated. In such a case, using sendmail is not really the best option. I'd be more apt to recommend using postfix, dovecot, claimav and spamassassin to manage this more efficiently.

The setup for all four isn't quick by any means, though there are a few alternative options to speed up that process. I know that there was a post, IIRC, here in the community that highlighted a shell script that would automatically handle setting all of this up for you.

If you're wanting to physically host e-mail accounts, I'll see if I can dig up that link. Many of the tutorials around the web (i.e. Google results) are outdated, missing steps etc - so I don't put much faith in them. I do know, however, that if I can find the link, this script does work and it will keep you from pulling your hair out :-).

  • @jtittle


    Thank you so much for your help. I've got the hostname set to web.roypenrod.com and the domain name resolves to my main site. I set up my DNS a few days ago following the instructions in your original reply.

    As far as email goes, let me just tell you what I want in plain english.

    (1) I only want one email address set up for my domain: roy@roypenrod.com. I would prefer using a webmail program to interact with it, but I don't care if that webmail program is running on my own server or not. I just want to reliably send and receive email at roy@roypenrod.com and have my emails appear to come from that email address.

    (2) I want to reliably send an email through a PHP script to both my own email address and an external email address. I'm fine sending it through a more reliable external SMTP server if that's what I need to do.

    The problem is I'm so new to Linux, I don't know what I should do. I'm just getting comfortable with the command line. I'm learning my around the shell. I installed the LAMP stack droplet, but I've never configured a web server.

    I'm comfortable with front-end development and writing PHP scripts that talk to a mySQL database. I've always used shared hosting, so I've never had to dig under the hood like this.

    But that's why I'm here. I need to learn this stuff. I'm trying to start a career in web development and I'd like to end up as a full-stack developer for LAMP to start with and then expand to MEAN and Ruby on Rails later on.

    So what should I do? What do you recommend given my situation?



Found one of them :-).


It's been a little while since I've used this one, though it's complete, has a web GUI, and will handle a ton of the technical aspects of the setup associated with allowing your web server to handle incoming and outgoing mail.

I would download the source from the link above to your local computer first, read over the docs, and deploy a 1GB Droplet for a few hours. This will allow you to tinker with the script without any changes to your current droplet (if it's hosting content).

If you have an extra domain that's not in use, you could set the DNS for that domain to the new Droplet, which would allow you to test mail setting once everything is setup.

From there, installing Apache/NGINX/Caddy, PHP and other software on top would be all that needs to be done.


I will say, however, that if you plan on running a mail server, web server and database server all from a single Droplet, I would advise a 1GB minimum, 2GB preferred for optimal performance and room as the software that runs in the background can be a little demanding at times.

I just setup my domain with mail server a few days ago, I'll share another pointer:

my 2 cents (may be over valued):

After installing the software already mentioned here, I had to change the name of my droplet (from the digital ocean web control panel) to my full domain name, in your case, roypenrod.com. I was just using a nickname with no TLD when I originally set it up.

This allows the reverse dns lookup of your ip address (PTR record) to properly show your domain name. If your IP does not properly reverse DNS to your domain name, most of your e-mail will be marked as spam.

So after I did that and set my hostname, configured sendmail.mc, added the iptables firewall rule, etc... I sent out a few test emails to my other email accounts. A GoDaddy account and a Hotmail account. I never received them, so I checked my sendmail log and the mail servers (Hotmail and GoDaddy) said my ip address had been black listed for spam. Maybe a previous owner, I'm not sure, because I haven't sent any mail at all from this ip address since I've had it (< 2 weeks).

So I had to contact outlook.com (sender information form https://support.live.com/eform.aspx?productKey=edfsmsbl3&ct=eformts&wa=wsignin1.0&scrx=1) to ask to be removed from the spam list. Same with GoDaddy, but it was a different contact website.

After a couple of days my e-mails started going through and working, but I'm not sure how many other blacklists my IP is on, so running an email service from my server may not be very reliable.

I can receive e-mails no problem to my domain, but if I'm sending an email to an address I've never e-mailed before, there is no guarantee it will go through. If I wanted to setup a reliable email service, perhaps www.mandrill.com or something similar.

  • @dusty225

    You would be correct about the PTR Record. Many e-mail service providers perform a reverse lookup and if what they find does not match, it's very likely that the result will be rejection and in extreme cases, blacklisting (extreme could be a mere 2-3 rejected e-mails -- especially for a SP such as Google or Yahoo -- 2-3 rejections multiplied by multiples over would be millions++ of rejections if they didn't implement such a policy).

  • @dusty225

    I think something similar is happening now that I've got the hostname set up correctly. Thanks for the info. I really appreciate your help.

    And thanks for mentioning mandrill.com. That looks interesting.

    • @RoyPenrod - Mandrill is actually really nice and they offer an API as well (with various SDK's, including one for PHP). You could also check MailGun (by RackSpace) as well as SendGrid too (both offer an API and various SDK's as well). I've used all three in the past with no issues.

Have another answer? Share your knowledge.