Script Library: 1238 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Archive version of: massmailer.r ... version: 15 ... crazyaxe 31-Aug-2010

Amendment note: Corrected date bug || Publicly available? Yes

Rebol [title: "Mass mailer"

    version: 0.2.15

    author: "Massimiliano Vessi"

    date:  29/9/2009

    email: maxint@tiscali.it

     file: %massmailer.r

    Purpose: {"Mass emailng the world! Modify boundary if you use attachments."}

    ;following data are for www.rebol.org library

    ;you can find a lot of rebol script there

    library: [ 

        level: 'beginner 

        platform: 'all 

        type: [tutorial tool] 

        domain: [vid gui email ] 

        tested-under: [windows linux] 

        support: none 

        license: [gpl] 

        see-also: none 

        ] 



    ]

header-script: system/script/header



version: "Version: "

append version header-script/version

config: array 13


; the file %mass_mailer_conf.txt contains all configurations
; from 1-8 fields are settings
; 9 subject, and on are last usage configuration
; 10 body message
;  11 email list
; 12 boundary string
; 13 retard

;function to svae all data in mass_mailer_conf.txt file
salvatutto: func [ config] [
	write %mass_mailer_conf.txt ""
	foreach item config [
		write/append %mass_mailer_conf.txt item
		write/append %mass_mailer_conf.txt newline
		]
	]

either exists? %mass_mailer_conf.txt [

    config:  read/lines %mass_mailer_conf.txt 

    ] [

    alert "You must set access data. Please fill in data in Settings panel."

    ritardo: 2

    ]



configurazione_lay: layout [

    across

    title "Settings"

    return

    text "Your email:"

    email_fl: field  

    return

    text "SMTP server:"

    smtp_fl: field  

    return

    text "SMTP user:"

    smtpuser_fl: field

    return

    text "SMTP password:"

    smtppass_fl: field 

    return

    button "Save" [

        poke config 1  to-email email_fl/text    

        poke config 2  to-url smtp_fl/text

        poke config 7 to-string smtpuser_fl/text

        poke config 8  to-string smtppass_fl/text
	
	salvatutto config

        unview]

    button "Exit" [unview]  

    ]



aiuto_lay: layout [

    title "HELP"

    text 180 {This is a mass email, it permits to send any number of emails without problems. It will send an email each 2 seconds. 

    If you'll fill correctly settings panel, all will be alright. File loaded by Mass mailer must be in ASCII not in unicode. 

If you use attachments, use a correct boundary string.

    This program do his best with HTML email body. If you have problems, please contact me: maxint@tiscali.it }

    ]





controllo_emails: func [ lista] [

    lista_nera: copy []

    avvertire: false

    foreach indirizzo lista [

        temp2: length? parse indirizzo "@."

        if temp2 < 3 [  

            avvertire: true

            append lista_nera  indirizzo

            ]

        ]

    if avvertire = true [ alert reform ["The following addresses are NOT correct:" lista_nera ]]    

        

    ]


thedate: ""



assemblaggio: func [ /local thedate] [
	 either   attach_contr/data  [il_content: rejoin [ "multipart/related; boundary=^"" c_lay/text "^"" ] 
		] [
		il_content: "text/html; charset=ISO-8859-15" ]

		;we must set an correct RFC 822 standard format date
		;or our emails will be identified as spam
		
		clear thedate 
		if now/weekday = 1 [ append thedate "Mon, "]
		if now/weekday = 2 [ append thedate "Tue, "]
		if now/weekday = 3 [ append thedate "Wed, "]
		if now/weekday = 4 [ append thedate "Thu, "]
		if now/weekday = 5 [ append thedate "Fri, "]
		if now/weekday = 6 [ append thedate "Sat, "]
		if now/weekday = 7 [ append thedate "Sun, "]
		append thedate reform [parse (to-string now/date ) "-"]
		append thedate " "
		append thedate now/time
		append thedate " "
		tzone: (to-integer now/zone) / 3600
		either (sign? tzone) = 1 [ append thedate "+"] [ append  thedate "-"]
		if tzone < 10 [ append thedate "0"]
		append thedate tzone
		append thedate "00"
		
	set-net  config
	;now we construct the header
	il_header: make object! [   
		X-REBOL: "View 2.7.6.3.1 http://WWW.REBOL.COM"
		Subject:  to-string oggetto/text
		From:   to-email config/1
		Return-Path: to-email config/1
		To: to-email config/1
		Date: copy thedate
		MIME-Version:  "1.0"
		Content-Type: il_content
		]
	]


view layout [

    across

    title "Mass mailing"

    return

    btn-help [ view/new aiuto_lay]

    text  version

    return

    button "Settings" [

        

        email_fl/text: to-string config/1

        smtp_fl/text:  to-string config/2

        smtpuser_fl/text: to-string config/7    

         smtppass_fl/text: to-string config/8

        show [email_fl  smtp_fl smtpuser_fl smtppass_fl ]

        view/new configurazione_lay

        ]

    button "Reload last" [

    oggetto/text: to-string config/9

    a_lay/text: to-string config/10

    b_lay/text: to-string config/11

    c_lay/text: to-string config/12

    ritardo/text: to-integer config/13

    testo: read/string  to-file config/10

    db_mail2: read/lines to-file  config/11

    led1/data: true

    led2/data: true

    led3/data: true

    led4/data: true

    show [ oggetto a_lay b_lay c_lay led1 led2 led3 led4 ritardo]

    ]

    return

    led1: led

    text "Subject:"

    oggetto: field "subject" [led1/data: true

        show led1]

    return

    led2: led

    button "Body message" [ 

        corpo_ind: request-file 
	
	either  (parse (to-string corpo_ind)  [thru ".eml" end]) [
		a_lay/text: to-string corpo_ind
		show a_lay
		testo: read/string to-file corpo_ind
		led2/data: true
		show led2
		] [ alert "It isn't a valid eml file!"]
			

        ]

    a_lay: field "no text file loaded, html files are the best!"

    return

    led3: led

    button "Email list" [

        temp:  to-file request-file

        db_mail: read temp

        db_mail:  parse db_mail none

        sort db_mail 

        

        db_mail2: copy unique db_mail

        write/lines  temp db_mail2 ;scrive il file su hdd

    controllo_emails db_mail2

    b_lay/text: to-string temp

        show b_lay

        led3/data: true

        show led3

        ]

    b_lay: field "no email list file loaded"

    return
    text  "Do you want to use attachment or embedding images?"
    attach_contr: check true [ if not (attach_contr/data) [ hide [ led4 testo_bound c_lay] ]
		if attach_contr/data [ show [led4 testo_bound c_lay]]
		]
    return
    led4: led 

    testo_bound: h3 "Boundary string (optional)" 

    c_lay: field "es. boundary" [led4/data: true 

                                    show led4

                                    ]

    return

    text "Retard:"

    button 22x22 "+" [temp: to-integer ritardo/text

    temp: temp + 1

    ritardo/text: to-string temp

    show ritardo]

    ritardo: field  40 "2"

    button 22x22 "-" [temp: to-integer ritardo/text

    temp: temp - 1

    if temp < 1 [temp: 1]

    ritardo/text: to-string temp

    show ritardo]

    

    

    return

    button red "MASS MAILING!" [
	assemblaggio ;we now assemble the email

        

        counter: 0

        b: length? db_mail2

        a: confirm reform ["You are going to send" b "emails. I already deleted double entries. Do you want to proced?"]

        if a = true [

    ;saving configurations

    poke  config 9  to-string oggetto/text

    poke  config 10 to-file a_lay/text ;body message

    poke  config 11 to-file b_lay/text ; emails list

    poke  config 12 to-string c_lay/text ; boundary string
    poke  config 13 to-string ritardo/text ; retard

    salvatutto config ;save configuration

    ;sending emails

            foreach record db_mail2 [ 

                il_header/To:  record

                counter: counter + 1

                sped_lay/text: reform ["Sending email n." counter]

                show sped_lay

                send/header     ( to-email record )    testo   il_header

                wait to-integer ritardo/text
		
		        write %errors.log  reform ["Last sent email is: " record]


                ]   

            alert reform ["Finished! You sent" counter "emails."]

            sped_lay/text: reform [ "Finished! You sent" counter "emails." ]

            show sped_lay           

            ]

        ]

        

    return

    sped_lay: text red "____________________________"

    

    ]
Notes