1

I am trying to stream over text and get values that can be assigned to sender and recipient to send mail with 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"]].

My other Question is

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

How can i check this and see if mail was successfully sent

Irfan
  • 303
  • 1
  • 8
  • If SMTPClient doesn't throw an error, then it successfully delivered the mail to your mail server. You cannot, in general, do better than that without receiving an explicit reply from the owner of the email address - an ACK, as it were. – Frank Shearar Feb 05 '13 at 11:32

1 Answers1

3

Please separate your questions so we can answer properly. An answer to your first question:

| 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]].

I think you should have a look at the PharoByExample book. You can download it for free on the official website: http://pharobyexample.org/

Damien Cassou
  • 2,555
  • 1
  • 16
  • 21