You can not use two workarounds mail mail under linux lnmp

After configuring lnmp environment, there is a problem mail function can not send mail, in fact, there are two ways, one is to use sendmail component, but use postfix.

A method, use sendmail mail components 
  1. sendmail component mounting 
  yum the install sendmail 
  2. Use the following command to restart php-fpm process 
  /etc/init.d/php-fpm the restart 
  3. sendmail is operating properly detect 
  / etc / init .d / sendmail status 
  if the display is running running on it. 
  Command may be used 
  /etc/init.d/sendmail start (start the sendmail) 
  /etc/init.d/sendmail STOP (off the sendmail) 
  /etc/init.d/sendmail the restart (restart the sendmail) 
  4. Configuration php.ini fill in the absolute path to sendmail 
  using the edit command to open the php.ini 
  vi /usr/local/php/etc/php.ini 
  input? Find sendmail_path positioning (or manual jump to find sendmail_path), you will find the following code by default 
  ; sendmail_path = 
  press i to enter edit, modify these behaviors 
  sendmail_path = / usr / sbin / sendmail  -t -i
  press Esc to exit edit , enter: wq to save and exit 
  5. restart php-fpm process 
  /etc/init.d/php-fpm restart 
  so successful, if not assured, create a php file named mail.php, you can use the following code to test next. 
  "? PHP 
  T X T = " H E L L O , Y O U A R & lt E A G O O D B O Y ! " ; / / In case the email box to the address changed to your of   txt = "hello, youareagoodboy!" ; // the following into your e-mail address = mail '[email protected]'; 
  // send a message 
  mail ( m A I L , " M Y S U B J E C T " , mail, "Mysubject", TXT); 
  echo 'Message Sent WAS! '; 
  ?
  Save and upload it to your web root directory and run in the browser: 
  HTTP: // to your URL /mail.php 
  time you should be able to receive e-mail messages, but basically junk mail inside, attention view, if not receive mail, then check the time during normal operation, there are wood reboot or restart sendmail php. In general, you can normally receive the message. 
  Of course, the function is to achieve, but when using the above test code to test and found success send an email very slowly, tens of seconds or even a minute better time. Then I published in a blog comment or reply is unusually slow, more than a psychological term users wait. This is imperative to optimize the efficiency, or only cut off this feature. 
  Online methods are many, many, to amend this document is to modify the file, feeling too much trouble, so to find the minimal operator to modify, and then succeeded. 
  Modify / etc / hosts, before the unmodified 
  127.0.0.1 localhost.localdomain localhost 
  modified 
  Hostname localhost 127.0.0.1 localhost.localdomain 
  view the host name of the machine the command is: hostname 
  after the completion of modifications under sendmail restart 
  service sendmail restart 
  method two, if not you can try to use sendmail postfix mail 
  since the installation lnmp environment, under the mail lnmp the problem can not send mail function is still emerging, here, I do not recommend that you use sendmail as the sender, the reason is inefficient and slow. 
  yum remove sendmail 
  and then begin installing Postfix, and as opposed to the sendmail to efficiency is much higher, faster signaling rate, take up memory low, it can be said is the server letter first choice, of course, there are many great God will say smtp is also good, that there is no wrong, but personal preference, I like a simple letter of the server! 
  Install Postfix 
  yum install postfix 
  to change the default MTA to Postfix: 
  / usr / sbin / Alternatives -set the MTA /usr/sbin/sendmail.postfix 
  finished thing, whether the Postfix MTA changed again under examination: 
  Alternatives -display the MTA 
  configured Postfix, vi edit the main.cf 
  vi /etc/postfix/main.cf 
  open the following items were found, the front of the # removed, and do configuration: 
  myhostname = mail.2zzt.com 
  mydomain = 2zzt.com 
  myorigin = mydomain  inetinterfaces=all  mydestination=mydomain  inetinterfaces=all  mydestination=myhostname, localhost.mydomain, L O C A L H O S T , mydomain, localhost, mydomain 
  mynetworks = 192.168.100.10/28, 127.0.0.0/8 
  relay_domains = 
  home_mailbox = Maildir / 
  dislike vi online editing, can be downloaded directly upload main.cf /etc/postfix/main.cf server to replace it 
  to detect and start postfix 
  Service Status postfix 
  // if not start, execute the following command: 
  Service postfix start 
  setting boot 
  chkconfig postfix on 
  this point postfix be OK, but we still php.in get the absolute path in the configuration of sendmail! 
  Use the Edit command to open the php.ini 
  vi /usr/local/php/etc/php.ini 
  input? Find sendmail_path positioning (or manual jump to find sendmail_path), you will find the following code by default 
  ; sendmail_path = 
  Press i to enter edit, modify these behaviors 
  sendmail_path = / usr / sbin / sendmail  -t -i
  press the Esc key to exit the editor, enter: wq save and exit 
  restart php-fpm process 
  /etc/init.d/php-fpm restart 
  Linux lnmp under the mail function can not send e-mail solution introduced here, because sendmail low efficiency, more waste of time, is recommended to send mail using postfix

Guess you like

Origin www.cnblogs.com/phpk/p/10930318.html