Make note of any error messages, such as “relay denied” or “cannot connect to SMTP server.” These messages are the best source for determining which element in the email service architecture is incorrect. If you don’t receive the message, check the logs (see above). In a separate Eterm or Solar window, try sending an email. 1.) Create a file called mail.txt (or anything you like) in /mail.txt with vim or nano or your preferred text editor. To send a test message from the Linux command line, use the following command (replace with your email address): echo test | mail you don’t receive your email, check the logs (see above) for error messages. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company. Tell Postfix to process the queue now postqueue -fĭelete all queued mail postsuper -d ALL Send a test message from the command line Also, you can send an attachment with this command. mail -s 'Test Subject' < /dev/null -s is used for defining subject for email. Use few of below examples to send an email. Once you have checked the mail logs, the next step is to check the mail queue for pending and differed email messages. Using ‘mail’ Command mail command is most popular command to send emails from Linux terminal.
One thing that must be kept in mind is that, mailutils allows us to connect to a local SMTP (Simple Mail Transfer.
USING THE MAIL COMMAND IN LINUX INSTALL
It can be done by: sudo apt install mailutils. To take advantage of this command, we need to install a package named mailutils. To view the last 10 log messages and monitor the file, run: tail -f /var/log/maillog Check the mail queue The mail command is a Linux tool, that allows a user to send emails via a command-line interface. Once you have confirmed that the MTA is relaying to the correct SMTP server, the next step is to check the email service logs. Next, verify that your system is pointing to the correct SMTP relay server.įor systems using postfix, the command is: grep ^relayhost /etc/postfix/main.cfįor systems using sendmail, the command is: grep ^DS /etc/mail/sendmail.cf Check the mail logs On the other hand, you can send email from any of the commands that are available within Linux, such as mutt, SSMTP, telnet, and more. In order to work properly we should install the bsd-mailx package like below. If it returns a link to “/usr/sbin/ndmail”, your system is configured to use sendmail. Using both the mail command and the Shell script is available at the same time. Install mailx Command Linux distributions provides two mailx command one from the mailutils package which is installed by default and the other one is from the bsd-mailx package. If the command returns a link to “/usr/sbin/sendmail.postfix”, your system is configure to use postfix. To determine which MTA you are running, use the following command: ls -l /etc/alternatives/mta If you are running an older system, you may be using the sendmail MTA. Currently, Eclipse Linux servers are configured using the postfix MTA. First, determine which mail transfer agent (MTA) you are using.