Linux server status mail

How to check if SMTP is working from commandline (Linux) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

I have a SMTP-server, for the purpose of this question lets call it: smtp.mydomain.example . How do I check if the SMTP-server is in working? Can I send emails manually from Linux commandline?

@Flexo Shouldn’t such questions be migrated rather than closed ? This one looks like it belongs to Serverfault

@Balmipour old questions can’t be migrated, even by moderators. There are good reasons for this discussed on meta.stackexchange.com (I don’t have a link to hand right now), but note that the question isn’t deleted.

After checking several posts on Meta, it seems (to me) migrating «just» needs to reopen first. Maybe this isn’t possible with old questions, btw. I guess you know that better than me. Anyway, thanks for your answer. A more relevant point I’ve read in meta posts was that migration seems to require a «particularly valuable» question. Not that this one is useless, but it’s not a jewel either. I don’t understand this much, since SO is overrated over other sites like ServerFault / Linux or Superuser, but I’ll keep the debate for another day (and it belongs to Meta anyway, not SO 🙂

4 Answers 4

Syntax for establishing a raw network connection using telnet is this:

So telnet to your SMTP server like

telnet smtp.mydomain.example 25 

And copy and paste the below

helo client.mydomain.example mail from: rcpt to: data From: test@mydomain.example Subject: test mail from command line this is test number 1 sent from linux box . quit 

Note : Do not forgot the «.» at the end which represents the end of the message. The «quit» line exits ends the session.

You should wait for the servers’s response to each command, and abort if you get and error (4xx or 5xx result code).

Читайте также:  Install packages in oracle linux

Instead of hello velanapps.com you should write helo velanapps.com and if you want to know which smtp extensions are available, you should write ehlo velanapps.com , as in SMTP Example

This answer was useful, however I omitted the first line in my tests. I stil got emails through from the smtp server. It would be helpful if you could include a little bit about what the velanapps.com domain is doing here. I am always wary when I see a domain used for something like this with no explanation as to what its doing with our data. Thanks.

The only thing about using telnet to test postfix, or other SMTP, is that you have to know the commands and syntax. Instead, just use swaks 🙂

thufir@dur:~$ thufir@dur:~$ mail -f Maildir "/home/thufir/Maildir": 4 messages > 1 thufir@dur.bouncem 15/553 test Mon, 30 Dec 2013 10:15:12 -0800 2 thufir@dur.bouncem 15/581 test Mon, 30 Dec 2013 10:15:55 -0800 3 thufir@dur.bouncem 15/581 test Mon, 30 Dec 2013 10:29:57 -0800 4 thufir@dur.bouncem 15/581 test Mon, 30 Dec 2013 11:54:16 -0800 ? q Held 4 messages in /home/thufir/Maildir thufir@dur:~$ thufir@dur:~$ swaks --to thufir@dur.bounceme.net === Trying dur.bounceme.net:25. === Connected to dur.bounceme.net. EHLO dur.bounceme.net MAIL FROM:  RCPT TO:  DATA . -> Date: Mon, 30 Dec 2013 14:33:17 -0800 -> To: thufir@dur.bounceme.net -> From: thufir@dur.bounceme.net -> Subject: test Mon, 30 Dec 2013 14:33:17 -0800 -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/ -> -> This is a test mailing -> -> . QUIT N 5 thufir@dur.bouncem 15/581 test Mon, 30 Dec 2013 14:33:17 -0800 ? 5 Return-Path: X-Original-To: thufir@dur.bounceme.net Delivered-To: thufir@dur.bounceme.net Received: from dur.bounceme.net (localhost [127.0.0.1]) by dur.bounceme.net (Postfix) with ESMTP id 52D162C3EFF for ; Mon, 30 Dec 2013 14:33:17 -0800 (PST) Date: Mon, 30 Dec 2013 14:33:17 -0800 To: thufir@dur.bounceme.net From: thufir@dur.bounceme.net Subject: test Mon, 30 Dec 2013 14:33:17 -0800 X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/ Message-Id: This is a test mailing New mail has arrived. ? q Held 5 messages in /home/thufir/Maildir thufir@dur:~$ 

It’s just one easy command.

Источник

Полезные команды для управления Postfix

В этой шпаргалке я собираю полезные команды postfix, которыми я часто пользуюсь. Для администрирования postfix в основном используются следующие пять команд:

Вывести текущую очередь postfix:

$ find /var/spool/postfix/deferred -type f | wc -l
$ find /var/spool/postfix/active -type f | wc -l
$ find /var/spool/postfix/incoming -type f | wc -l
$ find /var/spool/postfix/defer -type f | wc -l

Количество писем в очереди:

Количество писем в очереди на конкретный адрес:

$ mailq | grep info@vmblog.ru | wc –l

Вывести информацию о конкретном письме в очереди (список messageID можно вывести командой mailq):

команда mailq в postfix

$ postcat -vq messageID > out_message.txt

Читайте также:  Сервер мгновенных сообщений linux

Статистика по отклоненным письмам:

Список самых активных отправителей:

$ mailq|grep ^[A-F0-9] |cut -c 42-80| sort | uniq -c| sort -n

Информацию по очереди отправки на конкретный домен:

Принудительная отправка из очереди:

Принудительная отправка на домен:

Принудительная отправка сообщение по messageID:

Мягкий перезапуск очереди:

$ postfix stop
$ postsuper -r ALL
$ postfix start

Удалить все письма из очереди:

Очистить только очередь deffered:

Удалить сообщение по messageID

Удалить письмо из очереди по отправителю:

$ postqueue -p | tail -n +2 | awk ‘BEGIN < RS = "" >/spam@email\.com/ < print $1 >‘ | tr -d ‘*!’ | postsuper -d

Вывести текущие параметры postfix:

Информация по конкретному параметру:

$ postconf | grep smtp_helo_timeout

Изменить значение параметра postfix без перезагрузки:

$ postconf -e ‘message_size_limit = 20480000’

Проверить синтаксис конфигурационных файлов postfix:

Вывести настройки по-умолчанию:

Вывести только настройки, которые отличаются от дефолтных:

Источник

Linux server status mail

author image

Vikram Sahu 🦉

Published on 2019-08-19· Updated on 2022-08-16

The author voluntarily contributed this tutorial as a part of Pepipost Write to Contribute program.

Introduction

SMTP connection errors could be resolved in numerous ways but command line detects the error from the root quite easily. In this conundrum, Telnet is widely used to test SMTP connection breaks. Testing an email server with Telnet client is where we would focus, going forward with our solution. In this article we would be solving one of the most widely searched issues and a potential SMTP connection pain point for the developers. To check if SMTP is working from the command line (Linux), is one critical aspect to be considered while setting up an email server.

The most common way of checking SMTP from Command Line is using telnet, openssl or ncat (nc) command. It is also the most prominent way to test SMTP Relay. Let’s see how it works.

Note: these commands are Linux specific, so won’t work in other environments.

SMTP From Command Line — Some Important Commands


1. Telnet:
Used to communicate with another host using the telnet protocol. If the hostname is not provided it enters into command mode.

Note: If telnet is not available, copy and paste the command

2. ncat or nc: It’s a general purpose CLI tool used for port scanning, security tool, and monitoring tool.
Note: If ncat or nc is not available, copy and paste the below command

sudo yum install nmap-ncat -y

3. openssl: It’s a general purpose library that provides an open-source implementation of SSL and TLS protocol.
Note: If openssl is not installed, copy and paste the below command:

Читайте также:  Добавить маршрут умолчанию linux

Step 1: Checking SMTP Connection Using Telnet

Telnet to your host, you want to check connection. Smtp servers usually communicate over smtp ports 25, 2525,587. Telnet SMTP test is one the best ways to figure out your SMTP connection state.

Syntax : telnet [your hostname ] [port no]

telnet smtp.pepipost.com 25 [2525 | 587 ]

In order to quit telnet ctrl + ] and quit

Output: If it’s getting connected properly

You can even try sending email using telnet.

Output: If the connection is refused.

Step 2: Checking The SMTP Connection From Command Line Using Ncat Or Nc

Because ncat or nc has various functionality from the list of functionality we will just check the connection using the following command.

nc -v -u smtp.example.com 587

If it is successfully connected

[[email protected] auth]# ncat -v -u smtp.pepipost.com 587 Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Connected to 138.197.56.58:587.

If there is a problem connecting the host

[[email protected] auth]# ncat -v -u smtp.example.com 587 Ncat: Version 7.50 ( https://nmap.org/ncat ) Ncat: Could not resolve hostname "smtp.example.com": Name or service not known. QUITTING.

All of the above steps are used to check the SMTP connection from command line to a particular port of the host. The next step is used to communicate through a secure tunnel using TLS. TLS security is of paramount importance when it comes to email deliverability. Read our detailed blog on TLS Security (Highly Recommended).

Step 3: Checking SMTP Connection Over TLS Using Openssl

In order to set up a TLS encrypted connection to an SMTP server, you need openssl command.

openssl s_client -connect smtp.pepipost.com:587 -starttls smtp

Once you hit the above command,you see a lot of verbose.

Above all, when a connection is successfully established, then you will notice a 250 DSN.

Consequently, once you got 250 DSN you can start now your SMTP transaction now by using below command

EHLO i am here 250-smtpbny-lb2.pepipost.com 250-PIPELINING 250-SIZE 50000000 250-VRFY 250-ETRN 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN

this will give you supported verbose.

It will not respond if your SMTP server is not active.

These are some of the popular methods to check whether the SMTP connection is active on your machine. In case you have installed the SMTP correctly, but still getting an error while sending emails, then please refer this doc for more information.

Grade My Email
Check your spam now?

Netcorecloud’s toolkit is the solution to all your email problems.

Источник

Оцените статью
Adblock
detector