Rebol 编程/发送
外观
< Rebol 编程
SEND address message /only /header header-obj /attach files /subject subj /show
将消息发送到地址(或地址块)
SEND 是一个函数值。
- 地址 -- 地址或地址块(类型:电子邮件块)
- 消息 -- 消息文本。第一行是主题。(类型:任何)
- /only -- 仅向多个地址发送一条消息
- /header -- 提供您自己的自定义标头
- header-obj -- 要使用的标头(类型:对象)
- /attach -- 附加文件、文件或 [.. [文件名 数据]]
- 文件 -- 要附加到消息的文件(类型:文件块)
- /subject -- 设置消息的主题
- subj -- 主题行(类型:任何)
- /show -- 在 TO 字段中显示所有收件人
send: func [ {Send a message to an address (or block of addresses)} address [email! block!] "An address or block of addresses" message "Text of message. First line is subject." /only "Send only one message to multiple addresses" /header "Supply your own custom header" header-obj [object!] "The header to use" /attach "Attach file, files, or [.. [filename data]]" files [file! block!] "The files to attach to the message" /subject "Set the subject of the message" subj "The subject line" /show "Show all recipients in the TO field" /local smtp-port boundary make-boundary tmp from ][ make-boundary: does [] if file? files [files: reduce [files]] if email? address [address: reduce [address]] message: either string? message [copy message] [mold message] if not header [ header-obj: make system/standard/email [ subject: any [subj copy/part message any [find message newline 50]] ] ] if subject [header-obj/subject: subj] either none? header-obj/from [ if none? header-obj/from: from: system/user/email [net-error "Email header not set: no from address"] if all [string? system/user/name not empty? system/user/name] [ header-obj/from: rejoin [system/user/name " <" from ">"] ] ] [ from: header-obj/from ] if none? header-obj/to [ header-obj/to: tmp: make string! 20 if show [ foreach email address [repend tmp [email ", "]] clear back back tail tmp ] ] if none? header-obj/date [header-obj/date: to-idate now] if attach [ boundary: rejoin ["--__REBOL--" system/product "--" system/version "--" checksum form now/precise "__"] header-obj/MIME-Version: "1.0" header-obj/content-type: join "multipart/mixed; boundary=" [{"} skip boundary 2 {"}] message: build-attach-body message files boundary ] smtp-port: open [scheme: 'esmtp] either only [ address: copy address remove-each value address [not email? :value] message: head insert insert tail net-utils/export header-obj newline message insert smtp-port reduce [from address message] ] [ foreach addr address [ if email? addr [ if not show [insert clear header-obj/to addr] tmp: head insert insert tail net-utils/export header-obj newline message insert smtp-port reduce [from reduce [addr] tmp] ] ] ] close smtp-port ]