Jenkins: call the local building sendmail mail server to send mail

[Reserved: https://www.cnblogs.com/wolfshining/p/7656597.html ]

Application jenkins send mail mail server SMTP server can be local or may be remote, the remote is not to say, in this talk about how to set up a mail server on jenkins local server, and send mail with jenkins, as detailed below:

A, linux server set up mail server:

  Here selection linux to build the sendmail mail server, the following steps:

   1, tools to prepare:

  Installation and configuration tools sendmail sendmail-cf

  Check that you have installed: rpm -qa grep sendmail *

  

  If the results are known, it is already installed, and did not look at the results of the installation:

  sudo yum install mailx -y

  sudo yum -y install sendmail

  sudo yum install -y sendmail-cf

  Continue to install SMTP Authentication Service (if required by an external SMTP service, then I have to use a local mail server, so do not use this)
  sudo yum -y install saslauthd

  2, configure sendmail:

  sudo vim /etc/mail/sendmail.mc 

  Find DAEMON_OPTIONS ( `Port = smtp, Addr = 127.0.0.1, Name = MTA ') dnl This line, change it to:

  DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl

  3, generate Sendmail configuration files:

  m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

  If the error: sendmail.mc: 10: m4: can not open `/usr/share/sendmail-cf/m4/cf.m4 ': No such file or directory

  Then the sendmail-cf is not installed successfully, reinstall it:

  sudo yum install -y sendmail-cf

  4, restart the sendmail service:

  sudo service sendmail restart 

  如果报错:sendmail:451 4.0.0 /etc/mail/sendmail.cf: line 91: fileclass: cannot open '/etc/mail/local-host-names': Group writable directory 
            451 4.0.0 /etc/mail/sendmail.cf: line 588: fileclass: cannot open '/etc/mail/trusted-users': Group writable directory

  或者Starting sendmail: 451 4.0.0 /etc/mail/sendmail.cf: line 91: fileclass: cannot open '/etc/mail/local-host-names': World writable directory
             451 4.0.0 /etc/mail/sendmail.cf: line 588: fileclass: cannot open '/etc/mail/trusted-users': World writable derectory [FAILED]

  In this way, then the problem is caused by file permissions, the following approach:

  Check the file permissions:

  ls -ld / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue

  dr-xr-xr-x. 23 root root 4096 Aug 31 02:55 /
  drwxr-xr-x. 93 root root 4096 Oct 11 18:31 /etc
  drwxr-xr-x 2 root root 4096 Oct 11 19:49 /etc/mail
  drwxr-xr-x. 15 root root 4096 Aug 31 16:03 /usr
  drwxr-xr-x. 18 root root 4096 Aug 31 02:55 /var
  drwxr-xr-x. 13 root root 4096 Oct 11 16:28 /var/spool
  drwx------ 2 root mail 4096 Oct 12 14:04 /var/spool/mqueue

  Modify /etc/mail/sendmail.cf file the following:

  sudo  vim /etc/mail/sendmail.cf

  Fw/etc/mail/local-host-names  --->改成:Fw-o /etc/mail/local-host-names

  Ft/etc/mail/trusted-users   --->改成:Ft-o /etc/mail/trusted-users

  /Etc/mail/submit.cf modify the contents of the file:

  sudo vim /etc/mail/submit.cf

  Ft/etc/mail/trusted-users --->改成:Ft-o /etc/mail/trusted-users 

  After editing reboot again:

  sudo /etc/init.d/sendmail restart

  After a successful start running status check:

  sudo /etc/rc.d/init.d/sendmail status

  sendmail (pid 21921) is running...

  sm-client (pid 21930) is running...

  Run successfully, then you can first send a test message

  5. Send a test message:

  mail -s "test" [email protected] < /home/opt/welcom.txt

  This in turn can /home/opt/welcom.txt content of the document as the message body, test messages sent to the mailbox as the title: [email protected] the

  OK, now, the mail server set up successfully, the next call in jenkins

Two, jenkins call the local sendmail mail server to send mail

  Appeal to build a sendmail mail server is a machine with jenkins, jenkins was set as follows:

  This simple, only need to configure two places to

  System Configuration:

  

 

 The two set about the place, and then send a test message, success

Guess you like

Origin www.cnblogs.com/channy14/p/11577980.html