Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: REBOL Mail List Changes

From: sf::sabufrancis::com at: 4-Dec-2003 9:45

Hi: Here is the complete, patched send function. (There was a small typo in my earlier post) I hope my email client does not word wrap this at the wrong places. Note that this is patched from the original "send" function, not the one that Ingo has written. Please let me know if this is the correct way to handle it as I have tested this only using Qmail. What is the experience with other servers? Regards Sabu Francis send: func [ "Send a message to an address (or block of addresses)" ;Note - will also be used with REBOL protocol later. 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 content do-send boundary make-boundary tmp from sendProperFrom ][ make-boundary: does [] do-send: func [port data] [ foreach item reduce data [ if string? item [replace/all item "^/." "^/.."] ] insert port reduce data ] sendProperFrom: func [ hObj s-port frm ] [ either get in hObj 'Return-Path [ do-send s-port ["MAIL FROM: <" hObj/Return-Path ">"] hObj/Return-Path: none ] [do-send s-port ["MAIL FROM: <" frm ">"] ] ] if file? files [files: reduce [files]] ; make it a block if email? address [address: reduce [address]] ; make it a block message: either string? message [copy message] [mold message] if not header [ ; Clone system default 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 ] ;-- Send as an SMTP batch or individually addressed: smtp-port: open [scheme: 'smtp] either only [ ; Only one message to multiple addrs ;commented out to handle Return-Path ;do-send smtp-port ["MAIL FROM: <" from ">"] sendProperFrom header-Obj smtp-port from foreach addr address [ if email? addr [ do-send smtp-port ["RCPT TO: <" addr ">"] ] ] insert insert message net-utils/export header-obj newline do-send smtp-port ["DATA" message] ][ foreach addr address [ if email? addr [ ;commented out to handle Return-Path ;do-send smtp-port ["MAIL FROM: <" from ">"] sendProperFrom header-Obj smtp-port from do-send smtp-port ["RCPT TO: <" addr ">"] if not show [insert clear header-obj/to addr] content: rejoin [net-utils/export header-obj newline message] do-send smtp-port ["DATA" content] ] ] ] close smtp-port ]