iT邦幫忙

0

PHP 無法寄信

php

php.ini 已設定 SMTP msa.hinet.net , 怎麼還是無法寄 , 搜尋網路沒找到解答

https://ithelp.ithome.com.tw/upload/images/20180415/20104326E20sEvaUHQ.png

https://ithelp.ithome.com.tw/upload/images/20180415/20104326d0sRk3exWy.png
https://ithelp.ithome.com.tw/upload/images/20180415/20104326tR6wEoUyct.png

看更多先前的討論...收起先前的討論...
1. mail body look this https://www.w3schools.com/php/func_mail_mail.asp
2. PHP.INI config

[mail function]
SMTP = ur smtp server
sendmail_from = ur name

[sendmail]
smtp_server=mail.yourdomain.com
smtp_port=25
default_domain=yourdomain.com
auth_username=
auth_password=
force_sender=you@yourdomain.com

more info look http://php.net/manual/en/ref.mail.php
msa.hinet.net 這個你的Server IP 要是中華電信的線路才可以免費使用@@..
其他非中華電信的線路是無法使用 msa.hinet.net
alex9453 iT邦新手 2 級 ‧ 2018-04-16 15:29:28 檢舉
我是用台哥大無線網路寄gmail,可以使用smtp.gmail.com?
gmail只要有帳號密碼就可以寄~再加上一些加密協定~請參考Google搜尋~
alex9453 iT邦新手 2 級 ‧ 2018-04-16 16:45:51 檢舉
照這個做就可以了嗎 ?
http://adon988.logdown.com/posts/1128411-how-to-use-phpmailer-and-winodws-locahlost-letter-to-match-the-gmail-smtp-server
jerry00218 iT邦好手 10 級 ‧ 2018-04-16 22:52:46 檢舉
發哥寫的好詳細!
IF U WANT USE GMAIL SMTP SERVER
FYI THIS LINK https://stackoverflow.com/questions/4095289/how-to-configure-php-ini-to-use-gmail-as-mail-server
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

1
jerry00218
iT邦好手 10 級 ‧ 2018-04-16 00:16:44

最後一張圖有提示你錯誤是什麼,你的 php.ini 中,你反白的下面幾行應該有一行是 sendmail_from,這個值被 comment 也沒有設定。

看更多先前的回應...收起先前的回應...
alex9453 iT邦新手 2 級 ‧ 2018-04-16 09:18:36 檢舉

謝謝回答, 你是說畫紅圈要設定嗎 ?
https://ithelp.ithome.com.tw/upload/images/20180416/20104326YPm8KXvTF5.png
https://ithelp.ithome.com.tw/upload/images/20180416/201043262VMkruHN5C.pnghttps://ithelp.ithome.com.tw/upload/images/20180416/20104326rHCTfh1hMU.png

wingkawa iT邦新手 3 級 ‧ 2018-04-16 10:33:59 檢舉
Parse error: syntax error, unexpected 'or' (下略)

語法錯誤,or不是放那邊的。

下次你可以直接貼錯誤訊息,不然好歹你截圖也裁一下唄
對於嘗試協助你解決問題的人來說,有太多不必要的雜訊,很難看

alex9453 iT邦新手 2 級 ‧ 2018-04-16 11:03:23 檢舉

謝謝回答,第二頁不是有錯誤訊息

wingkawa iT邦新手 3 級 ‧ 2018-04-16 11:41:31 檢舉

有阿,我的意思是說下次你可以直接複製貼上那一行就行了,而不是截整個桌面。

jerry00218 iT邦好手 10 級 ‧ 2018-04-16 22:51:36 檢舉

照著 wingkawa 方法有解決你的問題了嗎?

wingkawa iT邦新手 3 級 ‧ 2018-04-17 09:47:01 檢舉

這是你的語法:

if ( mail() ) or die('error');
{
    // do something...
}

這是正確的if用法:

if ( mail() ) {
    // do something
}

你應該要看得出來語法有哪邊怪怪的

0
竹本立里
iT邦好手 1 級 ‧ 2018-04-16 09:15:20

https://www.google.com.tw/search?q=PHP+無法寄信&oq=PHP+無法寄信&aqs=chrome..69i57j69i61.255j0j7&sourceid=chrome&ie=UTF-8

第4個
在 PHP.ini 裡頭

SMTP = msa.hinet.net
smtp_port = 25
sendmail_from = xxx@gmail.com

但沒看到你的程式碼有
sendmail_from = xxx@gmail.com

sendmail_from not set in php.ini or custom from
google 的翻譯
sendmail_from未在php.ini中設置或自定義

alex9453 iT邦新手 2 級 ‧ 2018-04-16 11:01:42 檢舉

我的程式碼是照書上打的
https://ithelp.ithome.com.tw/upload/images/20180416/20104326FBy3MvSUtw.jpg

我要發表回答

立即登入回答