當我在這些網站(超級用戶/stackoverflow/serverfault)上提問時,我感覺自己被拋棄了,所以如果我的問題在錯誤的地方,請原諒我並向我指出,我很樂意將其移至其他地方。
我一生都無法收到從我的 Gmail 帳戶發送到我的 ubuntu 伺服器的任何電子郵件。我使用 postfix 作為我的 MTA,起初我嚴格遵循這些說明,因為它們似乎是最直接和最通用的方法,但我似乎永遠無法使用這些說明將電子郵件發送到我的 Gmail 帳戶(失敗): https://help.ubuntu.com/lts/serverguide/postfix.html
經過很多很多小時的搜索和重試後,我隨機遇到了這個問題,並且許多人在答案的評論中聲稱這確實對他們有幫助,所以我想我會嘗試一下。當他的指示不起作用時,我收到了與他類似的錯誤訊息,最終,我得到了這些指令(在某種程度上): https://serverfault.com/questions/119278/configure-postfix-to-send-relay-emails-gmail-smtp-gmail-com-via-port-587
不幸的是 - 上述說明僅將電子郵件(從我的 linux/ubuntu)發送到我的 gmail。我最大的願望是接收從我的 gmail 發送到我的 linux/ubuntu 的電子郵件。注意可能會有所幫助我的 Ubuntu 是一個本地 Web 伺服器,在我的 Macintosh 筆記型電腦上運行。
編輯:我認為重要的是要聲明我在動態 dns (freedns.afraid.org) 服務指向的虛擬機器上使用 ubuntu,因為考慮到這是一個開發設置,我沒有靜態 IP。
這是我的 main.cf 和 master.cf 檔案供您選擇,如果您願意為我提供任何幫助,我將不勝感激。
主.參閱:
注意:您會注意到我的 #smtpd_tls_key_file 和 #smtpd_tls_cert_file 行已被註解掉。起初我對此感到厭倦,但我遵循的說明中的答案解釋了為什麼為了簡單起見可以將它們排除在外。
他的解釋如下:
現在,我作為系統管理員的 13 年時間並沒有被浪費,我可以透過 Gmail 從我的筆記型電腦發送電子郵件,而無需像其他人告訴您的那樣生成自簽署的 x.509 憑證。 /etc/postfix/main.cf 中新增的關鍵內容是 smtp_tls_security_level 設置,它可以告訴 Postfix 在連接到另一個支援 TLS 的 MTA 時可以發出 STARTTLS 命令。
我不喜歡將這些註釋掉,並且我願意使用密鑰和證書,但暫時沒有它們也可以工作,並且它使事情變得簡單。我只是選擇有效的方法。
# 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
smtp_tls_security_level = may
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = < my FQDN >
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = < my FQDN >
relayhost = smtp.gmail.com:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
這是我的 master.cf 文件,我在此文件中所做的唯一更改是
smtp inet n - n - - smtpd
那行 ^ 原來是這樣的
smtp inet n - - - - smtpd
說實話,我不太清楚這個微小的差異會帶來什麼,但在我查看的許多說明中都推薦了它,並且在發送/接收郵件的組合中沒有任何區別。
正如所承諾的,我的 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) (yes) (never) (100)
# ==========================================================================
smtp inet n - n - - smtpd
#smtp inet n - - - 1 postscreen
#smtpd pass - - - - - smtpd
#dnsblog unix - - - - 0 dnsblog
#tlsproxy unix - - - - 0 tlsproxy
#submission inet n - - - - 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 - - - - 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 - - - - qmqpd
pickup unix n - - 60 1 pickup
cleanup unix n - - - 0 cleanup
qmgr unix n - n 300 1 qmgr
#qmgr unix n - n 300 1 oqmgr
tlsmgr unix - - - 1000? 1 tlsmgr
rewrite unix - - - - - trivial-rewrite
bounce unix - - - - 0 bounce
defer unix - - - - 0 bounce
trace unix - - - - 0 bounce
verify unix - - - - 1 verify
flush unix n - - 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - - - - smtp
relay unix - - - - - smtp
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - - - - showq
error unix - - - - - error
retry unix - - - - - error
discard unix - - - - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - - - - lmtp
anvil unix - - - - 1 anvil
scache unix - - - - 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}
任何對您有用的幫助或啟發都會很棒,謝謝!