Score:0

Help with sendmail on new LAMP linux installation

cn flag

Hi I installed sendmail.

sudo apt-get install sendmail
sudo sendmailconfig # accept Y all defaults
echo "My test email being sent from sendmail" | /usr/sbin/sendmail [email protected]

I tried it with several email addresses as well as the spam box and emails are not being delivered. Next I looked into the ufw firewall and added the following.

sudo ufw allow 25
sudo ufw allow smtp

and this is how it looks like

Status: active

To Action From

--                         ------      ----
22/tcp                     LIMIT       Anywhere
Apache Full                ALLOW       Anywhere
25                         ALLOW       Anywhere
25/tcp                     ALLOW       Anywhere
22/tcp (v6)                LIMIT       Anywhere (v6)
Apache Full (v6)           ALLOW       Anywhere (v6)
25 (v6)                    ALLOW       Anywhere (v6)
25/tcp (v6)                ALLOW       Anywhere (v6)

Next I turned off the firewall sudo ufw disable

however still no email. My os is Ubuntu 20.04.3 LTS thanks.

FedKad avatar
cn flag
Your internet provider might not be allowing outbound smtp connections. What is the output of `telnet gmail-smtp-in.l.google.com. 25` command?
ru flag
Need your mail logs as well if you have an SMTP server. /var/log/mail.log will have details about why messages cant leave the system
in flag
Where is the server? If you’re using a machine on a home network, big email companies will silently drop the message. If you’re using Amazon EC2, then Amazon will block the message until you communicate with them to remove the block. If you’re with most other VPN providers, sending mail will also be blocked
ar flag
This [question ans answer](https://askubuntu.com/questions/564086/send-mail-as-from-my-personal-gmail-account) may help you, even though it does not use sendmail. The main issue as I see it is sender of the mail has to be authenticated. If you send the mail from your gmail account, rather than some random server, it may work.
Score:0
ru flag

First things first. Lets check what you are using: which sendmail

This should echo something like /usr/sbin/sendmail

Then do the test line you had before, but add the flag "-v" (without the quotes) before the sendmail command. It will echo the whole of the communication between sendmail and the mail server.

Assuming you haven;t actively blocked port 25, you should not need the firewall commands. All that is needed for sending mail is port 25.

But be prepared for gmail to block you. It can get quite sniffy if it thinks you are sending spam. If thats bad, wait until you try and send mail to a o365 mail account!


Yes. This is a message that you're sending an email without any sender verification. It is expecting that the sender has an SPF or DKIM record. Thats an ISP setting, not a mail MTA setting. Its a whole different ball game, and in my experience, a whole new level of pain.

Long story short: Mail receivers try to ensure that the mail they receive is from validated senders. Senders have to authenticate that they are actually able to send in the name of the email address that they claim to come from. That means the receiver will check with the senders ISP go get a number of DNS records which the receiver can validate.

This is far from trivial, if you are sending to Gmail. It means setting up the DNS records with your ISP.

This is a whole new level of complexity and is the reason why I only use sendmail to send messages from my server to my own email address. So, things like cronlog events get sent, or issues with the server. But for sending email to real users I use an O365 account.

You can do this all on Linux, but not in 5 minutes.

Ahdee avatar
cn flag
yah I think its a gmail thing, the error was, `050 550-5.7.26 This message does not have authentication information or fails to 050 550-5.7.26 pass authentication checks. To best protect our users from spam, the ` know any solution to this?
ru flag
Reread my answer - StackExchange didn't like me adding a reply to your reply and got very sniffy. It said I needed to refine the original answer.
Ahdee avatar
cn flag
thanks; yup the main thing is that I want to send cron job status. I'm thinking about getting a free account and set up an smtp instead.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.