2017-11-17 25 views
4

우선, 긴 게시물 인 경우 유감스럽게 생각합니다. 다른 포럼의 사람들이 중요하다고 생각한 모든 정보를 수집하려고합니다 (기억할 수 있음).PHP 메일()이 메일을 보내지 못함 | 접미사 구성 | 아파치 2 | Ubuntu 16.04

둘째,이 게시물에 대한 답변이 "명백한"경우 일지라도 사과드립니다.하지만 단순하게 만들기 위해 내가하는 일을 절대적으로 알지 못합니다.이 작업을 처음 시도합니다.

나는 PHP 메일()로 메일을 보내려고하지만, 학교에서 잘 작동하더라도 집에서 할 때마다 실패한다. (나는 학교와 집에서 PHP7을 모두 사용하므로 내 생각에 가정에서 내 서버 구성에서 온 것 같아.)

내가 결과에 어떤 긍정적 인 영향을 미칠 것 같았다 어느 것도이 파일 및 다른 파일을 업데이트하도록 요청하는 많은 자습서를 시도했습니다, 그래서 여기 내가 지금까지 무슨 짓을했는지 : 다음

sudo apt-get install postfix 

내가 접미사 구성 중에 "인터넷 사이트"와 "localhost"를 선택했습니다.

나는 /etc/postfix/main.cf을 열어 일부 튜토리얼로 다음 두 가지 변수 '값을 변경하고 포럼 답변 제안 :

inet_interfaces = loopback-only 
inet_protocols = ipv4 

내가 모두 master.cf을 게시합니다 및 울부 짖는 소리 main.cf를 도움이된다면.

나는/etc/hosts 파일을 변경하고 (나는거야 다음 줄

127.0.0.1 localhost localhost.localdomain facorreg 
여기

내가 sendmail.mc에 다음 행을 전체/etc/hosts 파일

127.0.0.1 localhost 
127.0.1.1 facorreg 
127.0.0.1 localhost localhost.localdomain facorreg 

# The following lines are desirable for IPv6 capable hosts 
::1  ip6-localhost ip6-loopback 
fe00::0 ip6-localnet 
ff00::0 ip6-mcastprefix 
ff02::1 ip6-allnodes 
ff02::2 ip6-allrouters 

추가되는 추가 끄트머리 전체 파일 울부 짖는 소리)를지나 마지막으로

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

, 나는 php.ini의

변경
sendmail_path = /usr/sbin/sendmail -t -i 

는 여기에 내가 야후 주소로 메일을 보내려고 할 때 /var/log/mail.log는 저에게 말한다 무엇 :

꽤 많이입니다
Nov 17 16:42:13 localhost postfix/pickup[6223]: C5925E20D41: uid=33 from=<www-data> 
Nov 17 16:42:13 localhost postfix/cleanup[8491]: C5925E20D41: message-id=<[email protected]> 
Nov 17 16:42:13 localhost postfix/qmgr[6224]: C5925E20D41: from=<[email protected]>, size=637, nrcpt=1 (queue active) 
Nov 17 16:42:14 localhost postfix/smtp[8493]: connect to mta6.am0.yahoodns.net[74.6.137.65]:25: No route to host 
Nov 17 16:42:14 localhost postfix/smtp[8493]: connect to mta5.am0.yahoodns.net[63.250.192.46]:25: No route to host 
Nov 17 16:42:14 localhost postfix/smtp[8493]: connect to mta5.am0.yahoodns.net[66.218.85.139]:25: No route to host 
Nov 17 16:42:14 localhost postfix/smtp[8493]: connect to mta7.am0.yahoodns.net[98.136.216.25]:25: No route to host 
Nov 17 16:42:14 localhost postfix/smtp[8493]: connect to mta7.am0.yahoodns.net[98.138.112.33]:25: No route to host 
Nov 17 16:42:14 localhost postfix/smtp[8493]: C5925E20D41: to=<[email protected]>, relay=none, delay=0.64, delays=0.25/0.09/0.29/0, dsn=4.4.1, status=deferred (connect to mta7.am0.yahoodns.net[98.138.112.33]:25: No route to host) 

. 여기

은 도움이 될 것입니다 경우 나도 몰라, 몇 가지 보완적인 정보입니다

main.cf :

# See /usr/share/postfix/main.cf.dist for a commented, more complete version 


# Debian specific: Specifying a file name will cause the first 
# line of that file to be used as the name. The Debian default 
# is /etc/mailname. 
#myorigin = /etc/mailname 

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) 
biff = no 

# appending .domain is the MUA's job. 
append_dot_mydomain = no 

# Uncomment the next line to generate "delayed mail" warnings 
#delay_warning_time = 4h 

readme_directory = no 

# TLS parameters 
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem 
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key 
smtpd_use_tls=yes 
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache 
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache 

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for 
# information on enabling SSL in the smtp client. 

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination 
myhostname = facorreg.home 
alias_maps = hash:/etc/aliases 
alias_database = hash:/etc/aliases 
mydestination = $myhostname, localhost, facorreg, localhost.localdomain, localhost 
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 
mailbox_size_limit = 0 
recipient_delimiter = + 
inet_interfaces = loopback-only 
inet_protocols = ipv4 

master.cf :

# 
# Postfix master process configuration file. For details on the format 
# of the file, see the master(5) manual page (command: "man 5 master" or 
# on-line: http://www.postfix.org/master.5.html). 
# 
# Do not forget to execute "postfix reload" after editing this file. 
# 
# ========================================================================== 
# service type private unpriv chroot wakeup maxproc command + args 
#    (yes) (yes) (no) (never) (100) 
# ========================================================================== 
smtp  inet n  -  y  -  -  smtpd 
#smtp  inet n  -  y  -  1  postscreen 
#smtpd  pass -  -  y  -  -  smtpd 
#dnsblog unix -  -  y  -  0  dnsblog 
#tlsproxy unix -  -  y  -  0  tlsproxy 
#submission inet n  -  y  -  -  smtpd 
# -o syslog_name=postfix/submission 
# -o smtpd_tls_security_level=encrypt 
# -o smtpd_sasl_auth_enable=yes 
# -o smtpd_reject_unlisted_recipient=no 
# -o smtpd_client_restrictions=$mua_client_restrictions 
# -o smtpd_helo_restrictions=$mua_helo_restrictions 
# -o smtpd_sender_restrictions=$mua_sender_restrictions 
# -o smtpd_recipient_restrictions= 
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject 
# -o milter_macro_daemon_name=ORIGINATING 
#smtps  inet n  -  y  -  -  smtpd 
# -o syslog_name=postfix/smtps 
# -o smtpd_tls_wrappermode=yes 
# -o smtpd_sasl_auth_enable=yes 
# -o smtpd_reject_unlisted_recipient=no 
# -o smtpd_client_restrictions=$mua_client_restrictions 
# -o smtpd_helo_restrictions=$mua_helo_restrictions 
# -o smtpd_sender_restrictions=$mua_sender_restrictions 
# -o smtpd_recipient_restrictions= 
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject 
# -o milter_macro_daemon_name=ORIGINATING 
#628  inet n  -  y  -  -  qmqpd 
pickup unix n  -  y  60  1  pickup 
cleanup unix n  -  y  -  0  cleanup 
qmgr  unix n  -  n  300  1  qmgr 
#qmgr  unix n  -  n  300  1  oqmgr 
tlsmgr unix -  -  y  1000? 1  tlsmgr 
rewrite unix -  -  y  -  -  trivial-rewrite 
bounce unix -  -  y  -  0  bounce 
defer  unix -  -  y  -  0  bounce 
trace  unix -  -  y  -  0  bounce 
verify unix -  -  y  -  1  verify 
flush  unix n  -  y  1000? 0  flush 
proxymap unix -  -  n  -  -  proxymap 
proxywrite unix -  -  n  -  1  proxymap 
smtp  unix -  -  y  -  -  smtp 
relay  unix -  -  y  -  -  smtp 
#  -o smtp_helo_timeout=5 -o smtp_connect_timeout=5 
showq  unix n  -  y  -  -  showq 
error  unix -  -  y  -  -  error 
retry  unix -  -  y  -  -  error 
discard unix -  -  y  -  -  discard 
local  unix -  n  n  -  -  local 
virtual unix -  n  n  -  -  virtual 
lmtp  unix -  -  y  -  -  lmtp 
anvil  unix -  -  y  -  1  anvil 
scache unix -  -  y  -  1  scache 
# 
# ==================================================================== 
# Interfaces to non-Postfix software. Be sure to examine the manual 
# pages of the non-Postfix software to find out what options it wants. 
# 
# Many of the following services use the Postfix pipe(8) delivery 
# agent. See the pipe(8) man page for information about ${recipient} 
# and other message envelope options. 
# ==================================================================== 
# 
# maildrop. See the Postfix MAILDROP_README file for details. 
# Also specify in main.cf: maildrop_destination_recipient_limit=1 
# 
maildrop unix -  n  n  -  -  pipe 
    flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient} 
# 
# ==================================================================== 
# 
# Recent Cyrus versions can use the existing "lmtp" master.cf entry. 
# 
# Specify in cyrus.conf: 
# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4 
# 
# Specify in main.cf one or more of the following: 
# mailbox_transport = lmtp:inet:localhost 
# virtual_transport = lmtp:inet:localhost 
# 
# ==================================================================== 
# 
# Cyrus 2.1.5 (Amos Gouaux) 
# Also specify in main.cf: cyrus_destination_recipient_limit=1 
# 
#cyrus  unix -  n  n  -  -  pipe 
# user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user} 
# 
# ==================================================================== 
# Old example of delivery via Cyrus. 
# 
#old-cyrus unix -  n  n  -  -  pipe 
# flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user} 
# 
# ==================================================================== 
# 
# See the Postfix UUCP_README file for configuration details. 
# 
uucp  unix -  n  n  -  -  pipe 
    flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) 
# 
# Other external delivery methods. 
# 
ifmail unix -  n  n  -  -  pipe 
    flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) 
bsmtp  unix -  n  n  -  -  pipe 
    flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient 
scalemail-backend unix - n n - 2 pipe 
    flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension} 
mailman unix -  n  n  -  -  pipe 
    flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py 
    ${nexthop} ${user} 

센드 메일.MC

또한
divert(-1)dnl 
#----------------------------------------------------------------------------- 
# $Sendmail: debproto.mc,v 8.15.2 2015-12-10 18:02:49 cowboy Exp $ 
# 
# Copyright (c) 1998-2010 Richard Nelson. All Rights Reserved. 
# 
# cf/debian/sendmail.mc. Generated from sendmail.mc.in by configure. 
# 
# sendmail.mc prototype config file for building Sendmail 8.15.2 
# 
# Note: the .in file supports 8.7.6 - 9.0.0, but the generated 
# file is customized to the version noted above. 
# 
# This file is used to configure Sendmail for use with Debian systems. 
# 
# If you modify this file, you will have to regenerate /etc/mail/sendmail.cf 
# by running this file through the m4 preprocessor via one of the following: 
# * make (or make -C /etc/mail) 
# * sendmailconfig 
# * m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf 
# The first two options are preferred as they will also update other files 
# that depend upon the contents of this file. 
# 
# The best documentation for this .mc file is: 
# /usr/share/doc/sendmail-doc/cf.README.gz 
# 
#----------------------------------------------------------------------------- 
divert(0)dnl 
# 
# Copyright (c) 1998-2005 Richard Nelson. All Rights Reserved. 
# 
# This file is used to configure Sendmail for use with Debian systems. 
# 
define(`_USE_ETC_MAIL_')dnl 
include(`/usr/share/sendmail/cf/m4/cf.m4')dnl 
VERSIONID(`$Id: sendmail.mc, v 8.15.2-3 2015-12-10 18:02:49 cowboy Exp $') 
OSTYPE(`debian')dnl 
DOMAIN(`debian-mta')dnl 
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE 
undefine(`confHOST_STATUS_DIRECTORY')dnl  #DAEMON_HOSTSTATS= 
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE 
dnl # 
dnl # General defines 
dnl # 
dnl # SAFE_FILE_ENV: [undefined] If set, sendmail will do a chroot() 
dnl # into this directory before writing files. 
dnl # If *all* your user accounts are under /home then use that 
dnl # instead - it will prevent any writes outside of /home ! 
dnl # define(`confSAFE_FILE_ENV',    `')dnl 
dnl # 
dnl # Daemon options - restrict to servicing LOCALHOST ONLY !!! 
dnl # Remove `, Addr=' clauses to receive from any interface 
dnl # If you want to support IPv6, switch the commented/uncommentd lines 
dnl # 
FEATURE(`no_default_msa')dnl 
dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl 
DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl 
dnl DAEMON_OPTIONS(`Family=inet6, Name=MSP-v6, Port=submission, M=Ea, Addr=::1')dnl 
DAEMON_OPTIONS(`Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl 
dnl # 
dnl # Be somewhat anal in what we allow 
define(`confPRIVACY_FLAGS',dnl 
`needmailhelo,needexpnhelo,needvrfyhelo,restrictqrun,restrictexpand,nobodyreturn,authwarnings')dnl 
dnl # 
dnl # Define connection throttling and window length 
define(`confCONNECTION_RATE_THROTTLE', `15')dnl 
define(`confCONNECTION_RATE_WINDOW_SIZE',`10m')dnl 
dnl # 
dnl # Features 
dnl # 
dnl # use /etc/mail/local-host-names 
FEATURE(`use_cw_file')dnl 
dnl # 
dnl # The access db is the basis for most of sendmail's checking 
FEATURE(`access_db', , `skip')dnl 
dnl # 
dnl # The greet_pause feature stops some automail bots - but check the 
dnl # provided access db for details on excluding localhosts... 
FEATURE(`greet_pause', `1000')dnl 1 seconds 
dnl # 
dnl # Delay_checks allows sender<->recipient checking 
FEATURE(`delay_checks', `friend', `n')dnl 
dnl # 
dnl # If we get too many bad recipients, slow things down... 
define(`confBAD_RCPT_THROTTLE',`3')dnl 
dnl # 
dnl # Stop connections that overflow our concurrent and time connection rates 
FEATURE(`conncontrol', `nodelay', `terminate')dnl 
FEATURE(`ratecontrol', `nodelay', `terminate')dnl 
dnl # 
dnl # If you're on a dialup link, you should enable this - so sendmail 
dnl # will not bring up the link (it will queue mail for later) 
dnl define(`confCON_EXPENSIVE',`True')dnl 
dnl # 
dnl # Dialup/LAN connection overrides 
dnl # 
include(`/etc/mail/m4/dialup.m4')dnl 
include(`/etc/mail/m4/provider.m4')dnl 
dnl # 
dnl # Default Mailer setup 
MAILER_DEFINITIONS 
MAILER(`local')dnl 
MAILER(`smtp')dnl 

include(`/etc/mail/tls/starttls.m4')dnl 
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA') 

:

ifconfig      
netstat -rn 

반환 :

enp0s25 Link encap:Ethernet HWaddr 68:f7:28:9f:88:9a 
      UP BROADCAST MULTICAST MTU:1500 Metric:1 
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
      collisions:0 txqueuelen:1000 
      RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) 
      Interrupt:20 Memory:e1300000-e1320000 

lo  Link encap:Local Loopback 
      inet addr:127.0.0.1 Mask:255.0.0.0 
      inet6 addr: ::1/128 Scope:Host 
      UP LOOPBACK RUNNING MTU:65536 Metric:1 
      RX packets:40037 errors:0 dropped:0 overruns:0 frame:0 
      TX packets:40037 errors:0 dropped:0 overruns:0 carrier:0 
      collisions:0 txqueuelen:1000 
      RX bytes:3357002 (3.3 MB) TX bytes:3357002 (3.3 MB) 

wlp4s0 Link encap:Ethernet HWaddr f4:06:69:69:fd:7f 
      inet addr:192.168.1.37 Bcast:192.168.1.255 Mask:255.255.255.0 
      inet6 addr: fe80::f089:fdf:b8be:3fe4/64 Scope:Link 
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
      RX packets:54313 errors:0 dropped:0 overruns:0 frame:0 
      TX packets:40329 errors:0 dropped:0 overruns:0 carrier:0 
      collisions:0 txqueuelen:1000 
      RX bytes:52589300 (52.5 MB) TX bytes:6690660 (6.6 MB) 

Kernel IP routing table 
Destination  Gateway   Genmask   Flags MSS Window irtt Iface 
0.0.0.0   192.168.1.1  0.0.0.0   UG  0 0   0 wlp4s0 
192.168.1.0  0.0.0.0   255.255.255.0 U   0 0   0 wlp4s0 

telnet mta6.am0.yahoodns.net 25 

반환

,534

마지막

telnet alt4.gmail-smtp-in.l.google.com 25 

반환 (내가 구글 계정에 메일을 보내려고 할 때부터) : 당신의 도움에 미리

Trying 74.125.28.26... 
Trying 2607:f8b0:400e:c04::1a... 
telnet: Unable to connect to remote host: Network is unreachable 

감사합니다.

+0

몇 가지 일반적인 팁 ... 포트 25의 텔넷이 실패한 것을 감안할 때 귀하의 결론에 동의해야합니다. 다음을 꼭 확인하십시오. - 연결할 때 사용할 수있는 다른 로컬 장치가 있습니까? 이것은 리눅스 박스에서 방화벽 설정 문제를 배제하는데 도움이 될 수 있습니다. - 인터넷 용 핫스팟을 통해 연결 해보십시오. –

답변

1

내 문제를 해결하기 위해 일부 설정을 엉망으로 만들었지 만 PHP 메일은 제 자리에있는 것들을 제외하고 다른 작업 환경에서도 제대로 작동합니다. 몇 가지 조사를 통해 내가 가진 동일한 이슈가있는 사람들이 인터넷 제공자 (Orange fr)로부터 온 것임을 알게되었습니다.

나는 그것이 의미가 있는지 여부는 모르지만, 제 경우에는 경험적 증거가 그런 식으로 지적하는 것 같습니다.

이제이 질문을 대답으로 설정하겠습니다.