Sending mail through the console with authorization in Linux - haylesableatifes
Sending mail through the console: In order to be aware of everything that is happening on the server, in addition to monitoring, it is useful to follow the standard letters that various services send. I'll tell you how to configure the server to send messages via common postfix with say-so on a third-party SMTP server. Too, this setting will glucinium used for sending chain mail through and through the Linux console with SMTP authorization.
By default, the minimal installation of the CentOS 7 distribution already includes the postfix mail host. I will use information technology. Standard server settings set not provide normal capabilities for sending chain armour. We will make some extra actions.
How to send mail through the console?
First, to be able to quickly check the sending of mail through the console, install the programmailx. Without it, when you try to get off a message to the console table, you volition have an error:
# mail service bash: mail: command not found
Ready to fix this, establis mailx.
# yum install mailx
Subsequently that, you hind end send messages from your server to the outside world, for instance, like this.
# df -h | mail -s "Disk usage" admin@mymail.com
The output of the df program line will flee to the mail.
But with standard settings, your email will either represent spammed or not received at all by the recipient role server, because your server does not experience the correct settings for sending mail (DNS entries, SPF, dkim, etc.). For the chain mail to be sent normally, you need to use an external mail host. Set up postfix to send topical anesthetic emails through an external server with SMTP authorization.
I took the nonpayment postfix configuration, cleared it of comments and spaces, added my settings to the end.
# cat /etc/postfix/main.cf
## DEFAULT CONFIG BEGIN ###################### queue_directory = / volt-ampere / spool / postfix command_directory = / usr / sbin daemon_directory = / usr / libexec / postfix data_directory = / volt-ampere / lib / postfix mail_owner = postfix inet_interfaces = localhost inet_protocols = complete unknown_local_recipient_reject_code = 550 alias_maps = hasheesh: / etc / aliases alias_database = haschisc: / etc / aliases debug_peer_level = 2 debugger_command = PATH = / bin: / usr / bin: / usr / local / BIN: / usr / X11R6 / bin ddd $ daemon_directory / $ process_name $ process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.suffix newaliases_path = /usr/BIN/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = / usr / share / human race sample_directory = /usr/share/doc/postfix-2.10.1/samples readme_directory = /usr/share/doc/suffix-2.10.1/README_FILES ## DEFAULT CONFIG END ###################### # The name of the server that the hostname command displays myhostname = centos7-test.xs.local # Here, logically, you need to leave only the domain, only in this case it is advisable to go away the stuffed name of the server to the sender subject area # the full name of the server appeared, so it's many convenient to parse avail messages mydomain = centos7-test.xs.local mydestination = $ myhostname myorigin = $ mydomain # The address of the server direct which we will send mail relayhost = mailsrv.mymail.com:25 smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hashish: / etc / postfix / sasl_passwd smtp_sasl_security_options = noanonymous smtp_tls_security_level = may
Create a file with information about the username and password for sanction.
# mcedit / etc / postfix / sasl_passwd
mailsrv.mymail.com:25 admin@mymail.com: password
Produce a DB file.
# postmap / etc / suffix / sasl_passwd
In real time you can restart postfix and test the work.
# systemctl resume suffix
We get off the test letter through with the console. Check the mail log.
# tail -n 10 / var / log / maillog
If you have a connatural erroneous belief on that point:
postfix / smtp [5420]: warning: SASL authentication failure: No worthy mechs found postfix / smtp [5420]: 24762774C6: to = <admin@mymail.com>, electrical relay = mailsrv.mymail.com [10.10.30.3]: 25, retard = 450, delays = 450 / 0.03 / 0.02 / 0, dsn = 4.7.0, status = deferred (SASL authentication failed; can not authenticate to server mailsrv.mymail.com [10.10.30.3]: no mechanics available)
Then you need to set up single more packages:
# yum install cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain
After that, resume the suffix and check the sending in the console. If everything is fine, then to the basic alias for root in/ etc / aliases, tally an international address where the mail addressed to root leave be duplicated. To cause this, edit the specified file, changing the finis line.
It was:
#root: marc
Became
pull: root, admin @ mymail.com
We update the credentials database:
# newaliases
That's all. Now all the letters addressed to the local anesthetic root, for example, reports from corn, will be duplicated to an external letter box, with sending via an external normal mail server. So the letters will be delivered commonly, without getting into spam (although not necessarily, there are also heuristic filters). Now it is convenient to use topical sending in scripts, without specifying additional parameters. Everything is already configured, you can use simple local delivery.
You have Successfully Subscribed!
Source: https://sprintally.com/sending-mail-through-the-console/
Posted by: haylesableatifes.blogspot.com
0 Response to "Sending mail through the console with authorization in Linux - haylesableatifes"
Post a Comment