emailgmailsmalltalkmail-serveryahoo-mail

How to send an email by Smalltalk application using Gmail / Yahoo / Outlook


Is it possible to send an email from Smalltalk using a Gmail account? I have configured my company mail server with Smalltalk to send email, but that's not going to cut it when I distribute the application. Answers with any of using Outlook, Yahoo or Gmail are acceptable.


Solution

  • You should state which Smalltalk you are using since there are different dialects and all have different ways of handling things like e-mail.

    In Pharo, check out the class SMTPClient. There are class methods that have example methods showing how to send e-mails.

    For VisualWorks, load the parcel NetClients and check out the classes MailMessage and SMTPClient.

    Here's an example of code that sends an e-mail in VisualWorks:

    (Net.SMTPClient host: Net.NetClient netSettings defaultOutgoingHost name)
            user: Net.NetClient netSettings defaultOutgoingHost netUser;
            send: (Net.MailMessage newTextPlain
                subject: 'This is the subject';
                from: 'my-email@gmail.com';
                to: 'your-email@gmail.com';
                text: 'This is the body';
                yourself).