您在這裡

mail function 設定問題

wilsondenq's 的頭像
wilsondenq 在 2012-01-31 (二) 01:01 發表

最近架設好了drupal開始使用
而當有使用者註冊會員時
就如同網路上所說 會發生警告訊息
warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\drupal\includes\mail.inc on line 193.
Unable to send e-mail. Please contact the site administrator if the problem persists.

因此先修改php.ini 檔案
將smtp填上gmail的smtp
然後port改成465

不過這樣依然會出現錯誤訊息

PHPMailer module requires the PHPMailer library to properly send mail. Please download the PHPMailer package for PHP5/6, extract the archive and copy its contents to the following location: modules/phpmailer/phpmailer/. Make sure the main PHPMailer class is located at modules/phpmailer/phpmailer/class.phpmailer.php.
因此繼續找資訊
接下來我安裝了phpmailer
安裝啟用後就可以填入所需要的smtp資訊

同時也先出現了說需要將class.phpmailer.php這檔案丟到指定目錄去
不過看到兩種版本
一個是放在 sites/all/modules/phpmailer/phpmailer/
另外一個是放在 module/smtp/phpmailer/

但是一樣都還是不行
Fatal error: require_once() [function.require]: Failed opening required 'modules/smtp/phpmailer/class.phpmailer.php' (include_path='.;C:\php5\pear') in C:\AppServ\www\gjnet\modules\smtp\smtp.module on line 266
想請問一下各位大大
能狗給小第一個比較清楚的操作步驟呢
謝謝

你用先php寫一個簡單的程式,
試試看mail()這個function能不能正常的運作。

從「Failed to connect to mailserver at "localhost" port 25」看起來似乎是你的smtp網址沒設到?

檢查一下這兩個設定:
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

確定php基本的mail可以寄送後再來試試看Drupal。

--------------------------------------------

Drupal的部分應該不需要另外裝module才對,
他核心本身就有提供寄信的function了。
http://api.drupal.org/api/drupal/includes--mail.inc/function/drupal_mail/7

我是神豬~神豬的神,神豬的豬.......

嗯 我補充一下好了
目前將server架在固定IP的主機
作業系統是Win7 32bit

其實我的目的是覺得
系統不用自動發信沒關係

使用者註冊只要資料庫有寫進去就好
我也沒有打算要讓網站上可以自動回信給使用者

我目前設定如下

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = localhost

曾經設定過的參數
[mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 465

; For Win32 only.
sendmail_from = XXXX@gmail.com

[mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 587

; For Win32 only.
sendmail_from = XXXX@gmail.com

不過對我來說有沒有寄信功能其實不是很重要
我只希望使用者註冊不要再出現錯誤訊息罷了

剛剛又測試了另一個
[mail function]
; For Win32 only.
SMTP = msa.hinet.net
smtp_port = 25

; For Win32 only.
sendmail_from = xxxxxx@msa.hinet.net

下面是錯誤訊息
warning: mail() [function.mail]: SMTP server response: 550 5.7.1 ... Relaying denied. Proper authentication required. in C:\AppServ\www\gjnet\includes\mail.inc on line 192.
Unable to send e-mail. Please contact the site administrator if the problem persists.

應該是沒有提供轉送服務,
你可以試試xuite,
我記得之前好像有提供。

------------------------------

如果不打算寄信的話,
可以從使用者管理中關掉。

我是神豬~神豬的神,神豬的豬.......

剛剛試了一下
我找了IIS設定
不過裡面居然沒有smtp相關設定選項
不知道win7問題出在哪邊...QQ

另外在使用者管理部分
Only site administrators can create new user accounts.
Visitors can create accounts and no administrator approval is required.
Visitors can create accounts but administrator approval is required.
應該只有這三種選項 似乎無法阻止系統發出註冊信

我有找到這篇文章
http://belleaya.pixnet.net/blog/post/27410978-%5B教學%5D-php-利用-phpmailer-透過-gmail-寄信
不過試過了似乎也沒有幫助
我再研究看看

ㄟ 成功了
自解

也給大家參考一下
首先呢

drupal有個smtp module
請先下載並安裝

接下來
下載PHPMailer-ML_v1.8.1
並且將裡面有個phpmailer(<-只要這個)資料夾複製到modules>smtp>裡面
而且請依照下面網址教學開啟SSL權限
http://belleaya.pixnet.net/blog/post/27410978-%5B教學%5D-php-利用-phpmailer-透過-gmail-寄信

最後
於drupal的管理介面
有個SMTP Authentication Support
把要的資訊填一填
而且要將
Enable debugging取消選取
Checking this box will print SMTP messages from the server for every e-mail that is sent.

同時也要更改php.ini的設定
兩個要一樣

這樣就成了