How to use Centos8 to send emails to external or intranet users? Look here, learn in seconds (detailed explanation)

Recently, I followed the teacher and learned how to enable intranet users to send emails to intranet users or extranet users in Centos8. Personally, I think it is still very amazing, so I want to share with you how this process is realized.

Preface : Before the experiment starts, we need to confirm whether the local yum warehouse network source is configured successfully. We can try yum install -y httpd. If this command is successfully installed or the command exists, it means that our yum warehouse is configured correctly. Because in the experiment, we need to manually yum some commands. If the yum warehouse is not configured, we will not be able to carry out our next work.

After completing the above steps, we can officially start our experiment!

Table of contents

1. Intranet users send emails to intranet users

1.1 Use yum to install mailx, sendmail command

1.2 Realize intranet users sending emails to intranet users

2. Intranet users send emails to extranet users

2.1 Experiment preparation

2.2 Enable internal users to send emails to external network users


1. Intranet users send emails to intranet users

1.1 Use yum to install mailx, sendmail command

1.1.1 Install mailx command

// Because I have installed it, it will show that it has been installed. If the first installation is successful, it can be seen at the end. 

1.1.2 Install sendmail command

//There will be a short wait for the installation here, please don't worry, it is a normal phenomenon.

1.1.3 Start sendmail service

Use the command as follows

Start the service: systemctl start sendmail  //It will take a while to start the service, it is normal, please don’t panic

View service startup status: systemctl status sendmail 

1.2 Realize intranet users sending emails to intranet users

1.2.1 What should I do if 550 Invalid User: xxx ....message not send error occurs when sending an email?

命令:echo "this is my first email" | mail -x "test"

echo " Mail content " | mail -x " Mail subject " recipient  //The content marked in red here can be replaced according to your own situation, the recipient is the user we created in linux

I believe that some students will encounter the above error message when sending emails. Let’s go directly to the vi /etc/mail.rc file and comment out the things I marked in the figure below. //①: If there is no error report, it means that we have already done the following steps, and you can ignore it ②: Or we have not completed the configuration of sending emails to external network users, of course no error will be reported, but we can only send emails to intranet users send email. As for how to configure it here, I won’t go into too much detail here. I will tell you about it in the steps of sending emails to external network users.

//It needs to be explained here. If you want to use intranet users to send emails to external network users, you need to remove the comments of these fields. I will show you later, and this is also a cumbersome place. Send Different users require us to comment back and forth.

1.2.2 Realize sending emails to intranet users

When we annotate the content that needs to be annotated above, and then use the relevant commands, no error will be reported, as shown in the figure:

At this time, we use the mail command to check whether the mail is sent successfully //Sometimes the mail will not be displayed immediately after we send it, please wait for a while and the result will be displayed in the mail

 //From the picture, we can see that the email subject, recipient, and sending content are consistent with what we sent, and the email is sent successfully!

2. Intranet users send emails to extranet users

2.1 Experiment preparation

Before doing this experiment, you need to go to the official website of mail.163.com to register an email address. If you have any, you can ignore it and log in directly.

2.1.1 After successful login, we click Settings

 2.1.2 Click the POP3/SMTP/IMAP option to enter

 2.1.3 Confirm service start 

 //If the service is not enabled, just follow the operation steps to enable the service. Here, everyone should remember the returned authorization code, because we will use it for subsequent operations 

2.2 Enable internal users to send emails to external network users

 2.2.1 Modify the /etc/mail.rc file

We mentioned this file in the steps for intranet users to send emails to intranet users, so we need to add the following lines //You can directly G to the last line, add it
set bsdcompat
set ssl-verify=ignore
set nss -config-dir=/etc/pki/nssdb
set smtp=smtps://smtp.163.com:465
set smtp-auth=login
set smtp-auth-user= [email protected] //User when everyone registers What is the name, just replace the red part with what
set smtp-auth-password= ABCADASDADADAS //Here, replace the red part with the authorization code we obtained above
set from= [email protected] //The user name of the registered mailbox

// Don't forget to save and exit after modification

2.2.2 Finish sending mail 

Send mail command: echo " intranet to extranet " | mail -s " email " [email protected]  //The difference here is that the recipient has become our extranet user [email protected] , what content do you want to send, what is the title of the email, and who is the recipient, just modify the red parts in order

We log in to mail.163.com to see if we have received the mail

 You can see that the title and content of the mailbox and the recipient are the same as we sent. Here I fill in the recipient for the experiment. You can try sending emails to your classmates.

Note: Everyone must keep your authorization code properly. If it is obtained by others, they will use your authorization code to log in to your mailbox, so that you can do bad things recklessly!

At this point, our experiment is complete. Thank you for watching. I hope that you can give a thumbs up and support after reading it. It is not easy to create. More quality articles will be updated in the future. Thank you!

Guess you like

Origin blog.csdn.net/m0_65463546/article/details/128508209