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;
boundary="tADGMYu6005485.1447431754/roypenroddotcom"
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)
This is a MIME-encapsulated message
--tADGMYu6005485.1447431754/roypenroddotcom
The original message was received at Fri, 13 Nov 2015 11:22:33 -0500
from localhost [127.0.0.1]
----- The following addresses had permanent fatal errors -----
<roypenrod123@yahoo.com>
(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
--tADGMYu6005485.1447431754/roypenroddotcom
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
--tADGMYu6005485.1447431754/roypenroddotcom
Content-Type: text/rfc822-headers
Return-Path: <roy@roypenroddotcom>
Received: from roypenroddotcom (localhost [127.0.0.1])
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
--tADGMYu6005485.1447431754/roypenroddotcom--
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.
Roy
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
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.
Summary: 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.
Found one of them :-).
https://github.com/andryyy/mailcow
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.
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:
hostname
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):
web.roypenrod.com
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.
web.roypenrod.com
The DNS entries would look like:
WildCard
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 :-).
Click below to sign up and get $100 of credit to try our products over 60 days!
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