Seite 1 von 3

kennt jemand eine sendmail lib für PureBasic

Verfasst: 14.09.2004 17:33
von wichtel
Ich habe zwar schon einmal smtp zu Fuß mit PureBasic gemacht und es hat auch funktioniert, aber warum das Rad zweimal erfinden.
Ich brauche Unterstützung für binary attachements und Authentication.
Danke
Michael

Verfasst: 14.09.2004 17:35
von remi_meier
Da gibts die freie Blat.dll.
http://www.geocities.com/toby_korn/blat/

Verfasst: 14.09.2004 17:38
von wichtel
Das klingt gut.
Blat.exe habe ich schon benutzt.

Kann ich diese dll auch fest einbinden, so das nur ein executable rauskommt?

Verfasst: 14.09.2004 17:51
von remi_meier

Verfasst: 14.09.2004 17:57
von wichtel
Sauber, Dankeschön.

Verfasst: 14.09.2004 18:18
von wichtel
Soweit sogut.
Jetzt müsste nur noch das versenden klappen.

Code: Alles auswählen

blat=OpenLibrary(#blat,path$+"blat.dll")
If blat
   ret=CallFunction(#blat,"sendblat","-t dest@abc.com -s 'test' base64 -attach "+path$+"qfmon.txt")
EndIf

so geht es nicht....
Wie übergibt man denn die Parameter and blat?

Verfasst: 14.09.2004 18:47
von remi_meier

Code: Alles auswählen

;===========================================================================
;-USAGE
;===========================================================================
; 
; syntax:
;   Blat <filename> -To <recipient> [optional switches (see below)]
;   Blat -install <server addr> <sender's addr> [<try>[<port>[<profile>]]] [-q]
;   Blat -profile [-delete | "<default>"] [profile1] [profileN] [-q]
;   Blat -h [-q]
; 
; -install <server addr> <sender's addr> [<try n times> [<port> [<profile>]]]
;      : set's SMTP server, sender, number of tries and port for profile
;        (<try n times> And <port> may be replaced by '-').
; 
; <filename>     : file with the message body ('-' For console input, End with ^Z)
; -To <recipient> : recipient list (also -t) (comma separated)
; -tf <recipient> : recipient list filename
; -subject <subj>: subject Line (also -s)
; -f <sender>    : overrides the Default sender address (must be known To server)
; -i <addr>      : a 'From:' address, not necessarily known To the SMTP server.
; -cc <recipient>: carbon copy recipient list (also -c) (comma separated)
; -cf <file>     : cc recipient list filename
; -bcc <recipient>: blind carbon copy recipient list (also -bcc) (comma separated)
; -bf <file>     : bcc recipient list filename
; -organization <organization>: Organization field (also -o And -org)
; -body <text>   : Message body
; -x <X-Header: detail>: Custom 'X-' header.  eg: -x "X-INFO: Blat is Great!"
; -r             : Request Return receipt.
; -d             : Request disposition notification.
; -h             : displays this help.
; -q             : supresses *all* output.
; -Debug         : Echoes server communications To screen (disables '-q').
; -noh           : prevent X-Mailer header from showing homepage of blat
; -noh2          : prevent X-Mailer header entirely
; -p <profile>   : send with SMTP server, user And port defined in <profile>.
; -priority <pr> : set message priority 0 For low, 1 For high.
; -server <addr> : Specify SMTP server To be used. (optionally, addr:port)
; -port <port>   : port To be used on the server, defaults To SMTP (25)
; -hostname <hst>: Select the hostname used To send the message
; -mime          : MIME Quoted-Printable Content-Transfer-Encoding.
; -enriched      : Send an enriched text message (Content-Type=text/enriched)
; -html          : Send an HTML message (Content-Type=text/html)
; -uuencode      : Send (binary) file UUEncoded
; -base64        : Send (binary) file using base64 (binary Mime)
; -try <n times> : how many time blat should try To send. from '1' To 'INFINITE'
; -attach <file> : attach binary file To message (may be repeated)
; -attacht <file>: attach text file To message (may be repeated)
; -ti <n>        : Set timeout To 'n' seconds.
; -u <username>  : Username For AUTH LOGIN (use with -pw)
; -pw <password> : Password For AUTH LOGIN (use with -u)
; -log <filename>: Log everything but usage To <filname>
; -plain         : Use AUTH PLAIN To login To SMTP server (use with -u -pw)
; -charset <cs>  : User defined charset.  The Default is ISO-8859-1
; 
; Note that If the '-i' option is used, <sender> is included in 'Reply-to:'
; And 'Sender:' fields in the header of the message.
; 
; Optionally, the following options can be used instead of the -f And -i
; options:
; 
; -mailfrom <addr>   The RFC 821 MAIL From: statement
; -from <addr>       The RFC 822 From: statement
; -replyto <addr>    The RFC 822 Reply-To: statement
; -returnpath <addr> The RFC 822 Return-Path: statement
; -sender <addr>     The RFC 822 Sender: statement
; 
; For backward consistency, the -f And -i options have precedence over these
; RFC 822 defined options. If both -f And -i options are omitted then the 
; RFC 821 MAIL FROM statement will be defaulted To use the installation-defined 
; Default sender address
; 
; EXAMPLES:
; 
; Blat -install smtphost.bar.com foo@bar.com          // Sets host And userid
; Blat -install smtphost.bar.com foo                  // Sets host And userid
; Blat -install smtphost.bar.com                      // Sets host only
; 
; Blat myfile.txt -subject "A file for pedro" -To foo@bar.com
; // Sends a file with subject line "A file for pedro"
; 
; Blat myfile.txt -subject "A file for pedro" -To foo@bar.com -q
; // Sends a file with subject line "A file for pedro" And does not print
; // informative messages on the console
; 
; Blat myfile.txt -subject "A file for mark" -To fee@fi.com -f foo@bar.com
; // -f option overrides the Default sender
; 
; Blat myfile.txt -subject "A file for pedro" -To foo@bar.com -i "devil@fire.hell"
; // -i replaces "From:" line address (but leaves Reply-To: And Sender: lines)
; 
; Blat myfile.txt -subject "animals" -To fee@fi.com -cc "moo@grass.edu,horse@meadow.hill"
; // -c mails carbon copies To users moo@grass.edu And horse@meadow.hill
; 
; Blat.exe BLAT.ZIP -subject "file to gil" -To foo@bar.com -base64
; // Sends the binary file BLAT.ZIP To Gilles in MIME Base 64 format
; 
; Blat.exe BLAT.ZIP -subject "file to gil" -To foo@bar.com -uuencode
; // Sends the binary file BLAT.ZIP To Gilles in the old UUEncode format
; 
; Blat myfile.txt -subject "oumpla" -To foo@bar.com -attach c:\myfolder\*.txt
; // Sends a file with subject line "oumpla", attach all files with extension "TXT"
; // in folder "myfolder" on drive "C:". Note: you must specify a filename/pattern,
; // "-attach .\*.*" will send all files in current folder.
; // "-attach ." will not send anything And WILL NOT GIVE YOU ANY WARNING.
; 
; Blat myfile.txt -To fee@fi.com -server smtp.domain.com -port 6000
; // sends the message through SMTP server smtp.domain.com at port 6000
; 
; Blat myfile.txt -To fee@fi.com -hostname friend
; // tells the SMTP that this computer is called "friend"
;
; The DLL works in exactly the same way as Blat.exe !
;
;Send(args)

;===========================================================================
;-ATTACHMENTS LIST
;===========================================================================

NewList Attachments.s()

;===========================================================================
;-PROCEDURES
;===========================================================================

;Send the mail
Procedure sendmail(AttachmentIncluded.b)
  Protected EmailString.s
  RecipientEmailAddress.s=mailto
  SenderEmailAddress.s=mailfrom
  MailServerHost.s=mailserver
  message.s=botschaft
    EmailString + "- -to "+ RecipientEmailAddress
    EmailString + " -f " + SenderEmailAddress
    EmailString + " -server " + MailServerHost
    EmailString + " -subject " + Chr(34) + subject + Chr(34)
    EmailString + " -body " + Chr(34) + message + Chr(34)
    ;Handle attachments
    If AttachmentIncluded
        ResetList(Attachments())
        While(NextElement(Attachments()))
            LongFileName.s = Attachments()
            ShortFileName.s = Space(1024)
            GetShortPathName_(LongFileName, ShortFileName, 1024)
            EmailString + " -attach " + ShortFileName
        Wend
    EndIf
    ;EmailString + " -log log.txt" ; Uncomment to write a debug log called 'log.txt'
    EmailString + " -try 5"
    EmailString + " -noh2"
    EmailString + " -q"
    EmailString + " -html"
    ;Send mail
    If OpenLibrary(1, "blat.dll")
        error=CallFunction(1, "Send", EmailString)
        CloseLibrary(1) 
    Else
        MessageRequester("Error", "blat.dll' could not be found or opened.", #PB_MessageRequester_Ok)
    EndIf
EndProcedure
  
  
  
  

Verfasst: 14.09.2004 19:10
von wichtel
Danke.
Jetzt geht es.
Die Error Codes sind nicht immer aussagekräftig.
Und mit den spaces ist er auch penibel.
Super.

Verfasst: 15.09.2004 10:43
von wichtel
Das ist mehr als geil.
Ich habe den dll importer benutzt und mir die blat userlib gemacht.
Email senden aus einem executable ist nun ein Kinderspiel.
Ihr habt euch ein Freibier verdient.
Danke.
Michael

Verfasst: 15.09.2004 11:28
von freedimension
wichtel hat geschrieben:Und mit den spaces ist er auch penibel.
Das steht auch so auf der HP der Blat-DLL

Mal ne andere Frage: Brauch ich nach dem Import der DLL selbige noch beim Kompilieren oder warum ist die Library so klein?