File: comment_mail-smtp.rb

package info (click to toggle)
tdiary 2.0.1-1sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 7,220 kB
  • ctags: 1,667
  • sloc: ruby: 20,044; lisp: 476; makefile: 91; sql: 32; sh: 31
file content (51 lines) | stat: -rw-r--r-- 1,774 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# comment_mail-smtp.rb $Revision: 1.8 $
#
# SMTPץȥȤäƥĥåߤ᡼Τ餻
#   ư
#
# Options:
#   ̤Ǥ(ĥåߥ᡼ϥץ饰):
#     @options['comment_mail.enable']
#          ᡼뤫ɤꤹ롣true()false(ʤ)
#          ̵false
#     @options['comment_mail.header']
#          ᡼Subject˻Ȥʸ󡣿ʬʤ褦˻ꤹ롣
#          ºݤSubjectϡֻʸ:-1פΤ褦ˡդȥֹ椬
#          դʸˡ%³ѻä硢
#          եեޥåȻ򸫤ʤĤޤաפʬ
#          ưŪղäʤʤ(ֹղä)
#          ̵ˤ϶ʸ
#     @options['comment_mail.receivers']
#          ᡼륢ɥ쥹ʸ󡣥ޤǶڤäʣǤ롣
#          ̵ˤɮԤΥɥ쥹ˤʤ롣
#  
#   tdiary.confǤΤ߻Ǥ:
#     @options['comment_mail.smtp_host']
#     @options['comment_mail.smtp_port']
#          줾졢᡼˻ȤSMTPФΥۥ̾ȥݡֹ档
#          ̵Ϥ줾'localhost'פȡ25ס
#
# Copyright (c) 2003 TADA Tadashi <sho@spc.gr.jp>
# You can distribute this file under the GPL.
#
def comment_mail( text, to )
	begin
		require 'net/smtp'
		host = @conf['comment_mail.smtp_host'] || 'localhost'
		port = @conf['comment_mail.smtp_port'] || 25
		Net::SMTP.start( host, port ) do |smtp|
			smtp.send_mail( text, @conf.author_mail.untaint, to )
		end
	rescue
		$stderr.puts $!
	end
end

add_update_proc do
	comment_mail_send if @mode =~ /^(comment|trackbackreceive)$/
end

add_conf_proc( 'comment_mail', comment_mail_conf_label ) do
	comment_mail_basic_setting
	comment_mail_basic_html
end