I'd be happy to write up instructions for the class, but I have not been able to get it working at all. And I've spent a considerable amount of time on it. The main requirement I have, different from SMTPClient class>>example, is that my smtp server requires authentication. Here is my best attempt based on Adrian's code below (the names have been changed to protect the innocent ;-) ... | smtpClient serverName login password messageText fromAddress recipientList | serverName := 'smtp.server.name'. login := 'login'. password := 'password'. messageText := 'From: test@mail.whatever To: "some@other.address" Subject: this is a test Hello from Pharo!'. fromAddress := 'from@email.address'. recipientList := #('to@email.address'). smtpClient := SMTPClient openOnHostNamed: serverName. smtpClient user: login. smtpClient password: password. [smtpClient initiateSession. smtpClient mailFrom: fromAddress to: recipientList text: messageText. smtpClient quit. ] ensure: [smtpClient close] When I run this code, I get a 'TelnetProtocolError'. I even tried changing SMPTClient>>deliverMailFrom: by adding in the 'user:' and 'password:' methods, and then re-testing 'SMTPClient example'... deliverMailFrom: fromAddress to: recipientList text: messageText usingServer: serverName | smtpClient | smtpClient := self openOnHostNamed: serverName. smtpClient user: 'login'. "Added this and the next line with valid credentials" smtpClient password: 'password'. [smtpClient initiateSession. smtpClient mailFrom: fromAddress to: recipientList text: messageText. smtpClient quit] ensure: [smtpClient close] but I get the same error. Just for kicks, and to prove my credentials are correct, I put together this script in Python, using the same credentials, and I get a successful email sent. import sys, smtplib, time mailserver = 'smtp.server.name'
From = 'from@email.address' To = 'to@email.address' Subj = 'test message' date = time.ctime(time.time()) text = ('From: %s\nTo: %s\nDate: %s\nSubject: %s\n\n' % (From, To, date, Subj)) text = text + 'this is a one line message from python' print 'Connecting...' server = smtplib.SMTP(mailserver) server.login('login','password') server.sendmail(From, To, text) server.quit()
So there is either a bug in the authentication aspect in Pharo or (more likely) I'm missing something. There are a very limited number of methods in then SMTPClient inheritance tree that can be used for this, and I've tried a bunch of combinations. Can anyone out there in Pharo-land test SMTPClient against a server that requires authentication? I'd really like to be able to send notifications via email. I've certainly put in my best effort to get it working. Thanks, Dan -----Original Message----- From: pharo-users-bounces@lists.gforge.inria.fr [mailto:pharo-users-bounces@lists.gforge.inria.fr] On Behalf Of Adrian Lienhard Sent: Tuesday, November 30, 2010 15:46 To: A friendly place where any question about pharo is welcome Subject: Re: [Pharo-users] SMTPClient issue Hi Dan, Authentication seems supported. You can send messages #user: and #password: to a SMTPClient instance. The methods are defined in the indirect superclass ProtocolClient. Something along the lines of smtpClient := SMPTClient openOnHostNamed: serverName. smtpClient user: 'login'; password: 'secret'. [ smtpClient initiateSession. smtpClient mailFrom: fromAddress to: recipientList text: messageText. smtpClient quit ] ensure: [smtpClient close] should work (not tested). HTH, Adrian BTW, when you manage to make it work and would like to help a bit, please write a short instruction that we can put into the class SMTPClient or the help system so that others have a faster start. On Nov 29, 2010, at 12:35 , Daniel Klein wrote:
Yes, my smtp server requires authentication, but I see nothing in Pharo that allows me to enter a password like it does for "POP3Client example".
Dan
-----Original Message----- From: pharo-users-bounces@lists.gforge.inria.fr [mailto:pharo-users-bounces@lists.gforge.inria.fr] On Behalf Of Adrian Lienhard Sent: Monday, November 29, 2010 4:54 To: A friendly place where any question about pharo is welcome Subject: Re: [Pharo-users] SMTPClient issue
It works for me... I changed the from, to, and the smtp server.
What does the error say? Maybe your smpt server requires you to authenticate?
Cheers, Adrian
On Nov 29, 2010, at 01:28 , Daniel Klein wrote:
I can't seem to get:
SMTPClient example
to work.
I changed the 'deliverMailFrom:', 'to:' and 'usingServer:' arguments to valid entries but I keep getting a 'TelnetProtocolError'.
Could someone else please test this out cos I think it's broken. Please prove me wrong ;-)
I'm using:
Pharo-1.1.1-- Latest update: #11414
on Windows XP Pro SP3.
Dan