2012-11-02 70 views

回答

2

使用UserMailerMailAddress類:

global $wgPasswordSender, $wgPasswordSenderName; 

$from = new MailAddress($wgPasswordSender, $wgPasswordSenderName); 
$to = new MailAddress($user); 

$subject = "Thank you!"; 
$text = "This is a test. Blah blah blah..."; 

$status = UserMailer::send($to, $from, $subject, $text); 

if ($status->isGood()) { 
    // Great, it worked! 
} else { 
    // Something went wrong, deal with it... 
    // The $status object will have more information. 
} 

MailAddress構造函數採用一個User對象或地址和名稱。 $wgPasswordSender是MediaWiki用於發送密碼重置電子郵件和其他類似內容的默認電子郵件地址;你已經希望在你的LocalSetting.php中配置它。

+0

感謝的人。這代碼工作!!!! 我在'創建文章掛鉤'下添加了這段代碼,並將其放置在Hook.php中。像魅力一樣工作..感謝一噸! – jaga3421

+0

@ jaga3421:那麼你可以upvote並接受它。 – Wikis

+0

我做到了。謝謝你們 – jaga3421

相關問題