From: <lph...@us...> - 2009-04-10 20:31:41
|
Revision: 17918 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=17918&view=rev Author: lphuberdeau Date: 2009-04-10 20:31:26 +0000 (Fri, 10 Apr 2009) Log Message: ----------- Send wiki notifications through zend mail and add options to configure as SMTP Modified Paths: -------------- trunk/lib/mail/maillib.php trunk/lib/notifications/notificationemaillib.php trunk/lib/setup/prefs.php trunk/templates/tiki-admin-include-general.tpl trunk/tiki-admin_include_general.php Modified: trunk/lib/mail/maillib.php =================================================================== --- trunk/lib/mail/maillib.php 2009-04-10 20:18:49 UTC (rev 17917) +++ trunk/lib/mail/maillib.php 2009-04-10 20:31:26 UTC (rev 17918) @@ -47,4 +47,65 @@ } return $out_str; }// end function encode_headers + +function tiki_mail_setup() { + static $done = false; + if( $done ) { + return; + } + + require_once 'lib/core/lib/Zend/Mail.php'; + + global $prefs; + if( $prefs['zend_mail_handler'] == 'smtp' ) { + require_once 'lib/core/lib/Zend/Mail/Transport/Smtp.php'; + $options = array(); + + if( $prefs['zend_mail_smtp_auth'] ) { + $options['auth'] = $prefs['zend_mail_smtp_auth']; + $options['username'] = $prefs['zend_mail_smtp_user']; + $options['password'] = $prefs['zend_mail_smtp_pass']; + } + + if( $prefs['zend_mail_smtp_port'] ) { + $options['port'] = $prefs['zend_mail_smtp_port']; + } + + if( $prefs['zend_mail_smtp_security'] ) { + $options['ssl'] = $prefs['zend_mail_smtp_security']; + } + + $transport = new Zend_Mail_Transport_Smtp( $prefs['zend_mail_smtp_server'], $options ); + Zend_Mail::setDefaultTransport( $transport ); + } + + $done = true; +} + +function tiki_get_basic_mail() { + tiki_mail_setup(); + + return new Zend_Mail(); +} + +function tiki_get_admin_mail() { + global $prefs; + + $mail = tiki_get_basic_mail(); + $mail->setFrom( $prefs['sender_email'], $prefs['browsertitle'] ); + + return $mail; +} + +function tiki_send_admin_mail( $email, $recipientName, $subject, $textBody ) { + $mail = tiki_get_admin_mail(); + + $mail->addTo( $email, $recipientName ); + + $mail->setSubject( $subject ); + $mail->setBodyText( $textBody ); + + $mail->send(); +} + ?> Modified: trunk/lib/notifications/notificationemaillib.php =================================================================== --- trunk/lib/notifications/notificationemaillib.php 2009-04-10 20:18:49 UTC (rev 17917) +++ trunk/lib/notifications/notificationemaillib.php 2009-04-10 20:31:26 UTC (rev 17918) @@ -211,8 +211,7 @@ if (count($nots)) { $edit_data = TikiLib::htmldecode($edit_data); - include_once('lib/webmail/tikimaillib.php'); - $mail = new TikiMail(); + include_once('lib/mail/maillib.php'); $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]); $smarty->assign('mail_page', $pageName); $smarty->assign('mail_date', $tikilib->now); @@ -244,16 +243,19 @@ } foreach ($nots as $not) { - if (isset($not['hash'])) - $smarty->assign('mail_hash', $not['hash']); - $mail->setUser($not['user']); - $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_wiki_page_changed_subject.tpl"); - $mail->setSubject(sprintf($mail_data, $pageName)); - $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_wiki_page_changed.tpl"); - $mail->setText($mail_data); - $mail->buildMessage(); - $mail->send(array($not['email'])); - } + if (isset($not['hash'])) + $smarty->assign('mail_hash', $not['hash']); + + $mail_subject = $smarty->fetchLang($not['language'], "mail/user_watch_wiki_page_changed_subject.tpl"); + $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_wiki_page_changed.tpl"); + + tiki_send_admin_mail( + $not['email'], + $not['user'], + sprintf($mail_subject, $pageName), + $mail_data + ); + } } } Modified: trunk/lib/setup/prefs.php =================================================================== --- trunk/lib/setup/prefs.php 2009-04-10 20:18:49 UTC (rev 17917) +++ trunk/lib/setup/prefs.php 2009-04-10 20:31:26 UTC (rev 17918) @@ -1215,6 +1215,14 @@ //groupalert 'feature_groupalert' => 'n', + + 'zend_mail_handler' => 'sendmail', + 'zend_mail_smtp_server' => '', + 'zend_mail_smtp_auth' => '', + 'zend_mail_smtp_user' => '', + 'zend_mail_smtp_pass' => '', + 'zend_mail_smtp_port' => 25, + 'zend_mail_smtp_security' => '', ); // spellcheck Modified: trunk/templates/tiki-admin-include-general.tpl =================================================================== --- trunk/templates/tiki-admin-include-general.tpl 2009-04-10 20:18:49 UTC (rev 17917) +++ trunk/templates/tiki-admin-include-general.tpl 2009-04-10 20:31:26 UTC (rev 17918) @@ -146,6 +146,44 @@ <option value="LF" {if $prefs.mail_crlf eq "LF"}selected="selected"{/if}>LF {tr}(some Unix MTA){/tr}</option> </select> </div> +<div class="adminoptionbox"><label for="zend_mail_handler">Mail Sender</label> + <select name="zend_mail_handler" id="zend_mail_handler" onchange="if( this.value == 'smtp' ) show('smtp_options'); else hide('smtp_options');"> + <option value="sendmail" {if $prefs.zend_mail_handler eq 'sendmail'}selected="selected"{/if}>{tr}Sendmail{/tr}</option> + <option value="smtp" {if $prefs.zend_mail_handler eq 'smtp'}selected="selected"{/if}>{tr}SMTP{/tr}</option> + </select> +</div> +<div class="adminoptionboxchild" id="smtp_options" {if $prefs.zend_mail_handler neq 'smtp'} style="display: none;" {/if}> + <div class="adminoptionbox"><label for="zend_mail_smtp_server">SMTP Server</label> + <input type="text" name="zend_mail_smtp_server" id="zend_mail_smtp_server" value="{$prefs.zend_mail_smtp_server|escape}"/> + </div> + <div class="adminoptionbox"><label for="zend_mail_smtp_auth">Authentication</label> + <select name="zend_mail_smtp_auth" id="zend_mail_smtp_auth" onchange="if( this.value == '' ) hide('smtp_auth_options'); else show('smtp_auth_options');"> + <option value="" {if $prefs.zend_mail_smtp_auth eq ''}selected="selected"{/if}>{tr}None{/tr}</option> + <option value="login" {if $prefs.zend_mail_smtp_auth eq 'login'}selected="selected"{/if}>LOGIN</option> + <option value="plain" {if $prefs.zend_mail_smtp_auth eq 'plain'}selected="selected"{/if}>PLAIN</option> + <option value="crammd5" {if $prefs.zend_mail_smtp_auth eq 'crammd5'}selected="selected"{/if}>CRAM-MD5</option> + </select> + </div> + <div class="adminoptionboxchild" id="smtp_auth_options" {if $prefs.zend_mail_smtp_auth eq ''} style="display: none;" {/if}> + <p>{tr}These values will be stored in plain text in the database.{/tr}</p> + <div class="adminoptionbox"><label for="zend_mail_smtp_user">Username</label> + <input type="text" name="zend_mail_smtp_user" id="zend_mail_smtp_user" value="{$prefs.zend_mail_smtp_user|escape}"/> + </div> + <div class="adminoptionbox"><label for="zend_mail_smtp_pass">Password</label> + <input type="password" name="zend_mail_smtp_pass" id="zend_mail_smtp_pass" value="{$prefs.zend_mail_smtp_pass|escape}"/> + </div> + </div> + <div class="adminoptionbox"><label for="zend_mail_smtp_port">{tr}Port{/tr}</label> + <input type="text" name="zend_mail_smtp_port" id="zend_mail_smtp_port" value="{$prefs.zend_mail_smtp_port|escape}"/> + </div> + <div class="adminoptionbox"><label for="zend_mail_smtp_security">{tr}Security{/tr}</label> + <select name="zend_mail_smtp_security" id="zend_mail_smtp_security"> + <option value="" {if $prefs.zend_mail_smtp_security eq ''}selected="selected"{/if}>{tr}None{/tr}</option> + <option value="ssl" {if $prefs.zend_mail_smtp_security eq 'ssl'}selected="selected"{/if}>SSL</option> + <option value="tls" {if $prefs.zend_mail_smtp_security eq 'tls'}selected="selected"{/if}>TLS</option> + </select> + </div> +</div> </fieldset> <fieldset><legend>{tr}Logging and Reporting{/tr}</legend> @@ -470,4 +508,4 @@ </form> </td></tr></table> -</div> \ No newline at end of file +</div> Modified: trunk/tiki-admin_include_general.php =================================================================== --- trunk/tiki-admin_include_general.php 2009-04-10 20:18:49 UTC (rev 17917) +++ trunk/tiki-admin_include_general.php 2009-04-10 20:31:26 UTC (rev 17918) @@ -78,17 +78,24 @@ "urlIndex", "proxy_host", "proxy_port", - "ip_can_be_checked", + "ip_can_be_checked", "session_lifetime", "load_threshold", "site_busy_msg", "site_closed_msg", "helpurl", "tiki_version_check_frequency", - 'log_sql_perf_min', - "permission_denied_url", - "highlight_group", - "user_tracker_infos", + 'log_sql_perf_min', + "permission_denied_url", + "highlight_group", + "user_tracker_infos", + 'zend_mail_handler', + 'zend_mail_smtp_server', + 'zend_mail_smtp_auth', + 'zend_mail_smtp_user', + 'zend_mail_smtp_pass', + 'zend_mail_smtp_port', + 'zend_mail_smtp_security', ); foreach ($pref_simple_values as $svitem) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |