Errors while sending e-mail

[code] MailSocket.Address = “smtp01.xxxxxx.se” // your SMTP email server
MailSocket.Username = “noreply@xxxxxx.se”
MailSocket.Password = “password2mail”
MailSocket.Port = 25 // Check your server for the property port # to use

// Create the actual email message
Dim mail As New EmailMessage
mail.FromAddress = “jakob@syscare.se”
mail.Subject = “Test Email from Xojo”
mail.BodyPlainText = “Hello, World!”
mail.Headers.AppendHeader(“X-Mailer”, “Xojo SMTP Example”) // Sample header
mail.AddRecipient(“angelica@scrollbar.se”)

// Add the message to the SMTPSocket and send it
MailSocket.Messages.Append(mail) ----------->> error
MailSocket.SendMail ----------->> error[/code]

Error show is:
Type “POP3Socket” has no member named “Messages”
MailSocket.Messages.Append(mail)
Type “POP3Socket” has no member named “SendMail”
MailSocket.SendMail


Code is from the docs and I’ve looked in the Exampple Folder for sending e-mail, but simply, I don’t get it!
These members are not in other projekct and how do I add these!?

what superclass has MailSocket?

You have subclassed MailSocket from POP3Socket. Set its super to SMTPSocket.

Thank you!
Yes, you’re right!

No error messages, but also, no letter was sent. What could be the issue…!?

Add some event handlers to the socket. See http://documentation.xojo.com/index.php/SMTPSocket for the full list of events.

For example, add an Error event handler to your socket with the following code:

#if debugBuild then system.debugLog(currentMethodName + ", lastErrorCode = " + me.lastErrorCode.toText())

Now Xojo will print to the Messages log (third icon at the bottom of the IDE). Compare the error code to: http://documentation.xojo.com/index.php/SocketCore.LastErrorCode

Thank you!
Interesting! No eror shows!
I tried also with the MessageSent event, to print a message… but no difference!

No.,… I do these things all wrong!

Try using telnet to connect to your smtp host on port 25. Do you get a response? Most smtp hosts these days use Secure Sockets and port 465.

Jakob sent me his code earlier on and it works fine here as it is, on port 25. I sent myself several emails through his mail server.

Some ISPs block port 25 so maybe that’s what’s happening at Jakob’s end but there’s nothing else wrong with his code.

Yes, that was really nice of Garvin to take the time to look at the code!
I really didn’t expect all to take so much time.
I didn’t really felt comfortable sharing such details in public…

(But there are no secrets as such!)

I now look in Thunderbird, and settings are IMAP and on port 110.

Maybe my Swedish ISP, Telia, prevent me from using port 25? I will do some more investigation on these things as it is still the interesting idea. To use a dedicated Xojo-app to send e-mails.

But now, there is midsummer and midsummer in Sweden is magic!! :slight_smile:
Once in a lifetime, try spend a midsummer in Sweden!

I took a quick look at the Telia support page. I gather that the SMTP port is 465 and requires SSL. Here is what I found.

I used the Outlook on Windows page - just because I know the screens by heart. It helps pretend I can read Swedish.