1

我正在尝试通过文本流式传输并获取可以分配给发件人和收件人的值以使用 SMTPClient 发送邮件

 |message sender recipient Stream peek|
  message:= 'To: myemail@gmail.com, otheremail@yahoo.com 
             From: me@hotmail.com , ab@yahoo.com 
             Subject: mail test

             Simple mail from me.'.

  Stream:= message readStream.
  peek:= Stream next.
  peek = $T ifTrue[Stream position 2.
                   peek:= Stream next.
                   peek = $: ifTrue["How can  get everything For To: and From:
                                      as Senders and recipients"]].

我的另一个问题是

  SMTPClient 
  deliverMailFrom: sender
   to: recipient   
   text: message 
   usingServer: 'mail.mydomain'. 
  " ifTrue[Transcript show:('mail sent successfully')]"

我怎样才能检查这个,看看邮件是否成功发送

4

1 回答 1

3

请将您的问题分开,以便我们正确回答。回答您的第一个问题:

| message sender recipient stream subject |
message:= 'To: myemail@gmail.com, otheremail@yahoo.com 
           From: me@hotmail.com , ab@yahoo.com 
           Subject: mail test

           Simple mail from me.'.

stream := message readStream.
[stream atEnd] whileFalse: [
    line := stream nextLine trimBoth.

    (line beginsWith: 'To:') ifTrue: [recipient := line allButFirst: 'To: ' size].
    (line beginsWith: 'From:') ifTrue: [sender := line allButFirst: 'From: ' size].
    (line beginsWith: 'Subject:') ifTrue: [subject := line allButFirst: 'Subject: ' size]].

我认为你应该看看 PharoByExample 这本书。可以在官网免费下载:http: //pharobyexample.org/

于 2013-02-05T10:18:08.997 回答