How do I get sendmail to work?

I already configured my DNS and rDNS, and Linode said they have removed the restrictions from the ports. However, they also said that no services are listening on those ports, and I'm unable to send email. My simple test case is just:

sendmail some@address.com < a_text_file.txt

And I also need to be able to use PHP's mail() function.

I don't need to receive emails at this server at all.

When I try the above command, it spins for about a minute and then returns nothing. In the logs it says "unable to qualify my own domain name (localhost) -- using short name"

What is the simplest way to get this working? These are just system emails and they can come from any dummy address.

12 Replies

Hello,
Some operating systems may have Sendmail available as a package. You could try installing it. If that fails, you could install something like Postfix. Some installations of Postfix may allow anyone to send any email they want through your Linode by default, which is known as an open relay. You do not want this, you'll be open to bots sending spam emails, which will violate Linode's terms of service. A quick search revealed this guide which may be helpful in disabling this functionality.

You might also be interested in reading a list of Sendmail alternatives that may be helpful, but do your research and make sure any software that may be a mail server, isn't going to act as an open relay before you use it, and if necessary, reconfigure it so that it doesn't.

Good luck.

Blake

Hi Blake,

I don't really understand. I already have sendmail available at /usr/sbin/sendmail. I don't think I need an alternative; that's the standard library that PHP mail() uses. It just doesn't work. I also don't know if I need a "mail server" per se… I just want to send outgoing mail. Not sure where to find the instructions to get it to work.

Hello,
I could be wrong, but I think you will need some type of SMTP server if you're going to send email from your Linode using Sendmail. I believe Sendmail itself connects to an SMTP server at localhost. I, too, have often wondered if there is a way to send mail without the use of a local mail server of some kind, or a client that will connect to an external SMTP server and authenticate with any credentials you may have. I have never found a way to send mail without the use of an external SMTP server or a local one. Someone else may have a better suggestion for you, but to my knowledge, my previous post may be your best options to get this working for you.

Blake

Has anyone gotten this to work? Maybe sending mail with a Linode server is a rare thing, but it's hard to believe.

You can send mail via the "curl" utility if you can connect to some outside SMTP server. I use smtp2go.com.

You can also use the "ssmtp" utility if you don't want to use curl.

I think Sendmail can be configured to do something similar, I'm not entirely sure. However, if I understand correctly what @aprilwine is trying to achieve, it's the use of Sendmail without connecting to any external SMTP server, or running any local SMTP server, either of which I think is required to make Sendmail work properly.

Have you requested that Linode open the mail ports for you -- 465 (smtps), 587 (submission), 25 (smtp)? By default, Linode blocks all of these on new Linodes until you file a support ticket and request they be opened.

If you don't want to manage your own mail server (trust me on this…it's not for the faint of heart or for people who don't know what they're doing!), you can have your Linode relay mail through Gmail or some other commercial service that specializes in this.

Search this board…there's lots of suggestions about services to use and how to go about it.

See: https://linuxconfig.org/configuring-gmail-as-sendmail-email-relay

However, if you are intent on using sendmail, be advised that it is notoriously hard to configure because the content of it's configuration file is so cryptic and the configuration process so fraught with potential gotchas. I haven't dealt with it seriously since 2008 or so (4+ millennia ago in iOS years). I suppose it's gotten better since then but I'm still too afraid of it to even look at it.

-- sw

@stevewi, yes, I mentioned that in my original question. They opened the ports. I didn't realize that just sending a system email with a command-line tool required setting up an entire mail server, or that doing so was so impossibly difficult. I guess having email-based contact forms and other similar things on Linode isn't something that many people do?

I'll take a look at your link to see how to configure it… I think Drupal relies on PHP's mail() function, which relies on sendmail, but perhaps that can be changed in php.ini or something. Thanks for the pointers!

Looks like Gmail no longer allows "less secure apps" to use it for mailing, so the above article is out. Still searching… this ought to be one of the simplest things…

If you install postfix, the installation will replace /usr/sbin/sendmail with a work-alike that talks to postfix. I’m pretty sure exim & courier do the same.

So, you don’t have to wade through all the sendmail.mc/sendmail.cf gobbledygook to get a mail server working if you use another mail server.

@acanton77 has recommended something like “email in a box”. Search the boards for a link. It might just be exactly what you’re looking for.

— sw

"having email-based contact forms and other similar things on Linode isn't something that many people do?"

It is simple to do in WordPress with a plugin like this:

https://wpmailsmtp.com/

Docs are here: https://wpmailsmtp.com/docs/a-complete-guide-to-wp-mail-smtp-mailers/

recommended something like “email in a box”.

Mail-in-a-box works great although you need a (small) dedicated Linode to run it.

https://mailinabox.email/

The install will require a bit of tech expertise but if you can follow instructions you can get it done.

But Mail-in-a-box is actually an email server and I don't know how you would incorporate it into a contact form or something like that.

You might want to install and use the ssmtp utility as long as you have an external smtp provider. I use smtp2go.com which has a free tier.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct