Using SMTP for sending mail

I am using the SMTPsecureSocket for sending email. This results in an error message that states

Error 530 5.7.0 Must issue a STARTTLS command first.

What are the proper settings to avoid this error? Is there an example code somewhere for avoiding the TLS errors?
I have been using the SMTPsocket (with Real Studio 2012R2.1) successfully before the use of SSL was required.

Thanks for any help.

Sounds like you may need to use the SMTPSecureSocket class.

ConnectionType Property can set to either SSL v3 or TLS.

Some provider have a port for insecure, one for SSL direct and one for SSL with TLS.

To answer Phillip: Yes I’m using the SMTPsecureSocket.

I have the following code:

There is an SMTPsecureSocket named sendSocket on my active window.

In a “send” button’s action event I have

sendSocket.Address = my SMTP server name
sendSocket.Username = my SMTP user name
sendSocket.Password = my password
sendSocket.Port = 465
sendSocket.ConnectionType = 3
sendSocket.Secure = True

what happens if secure is set to false?
Because SSLSocket.TLSv1 switches later to secure, I think.

Sorry, secure = true may be needed, because else you turn off SSL.

[quote]I am using the SMTPsecureSocket for sending email. This results in an error message that states

Error 530 5.7.0 Must issue a STARTTLS command first.[/quote]

Sorry to tell you that this is probably one of those half baked Xojo features [SMTP socket] that Xojo never fixes.

Unless things recently changed the SMTP socket does not handle STARTTLS.

You will need to create your own from scratch or purchase someone else’s -and hope they’ve maintained it.

I don’t know why this company thinks half baking features like this is ok?

They’ve had many years to fix this issue and AFAIK they still haven’t.

I use a standard SMTPsocket called MailSocket and send the mail with the following Subroutine.

Sub SendTheMail
Parameters strTo As String, strSubject As String, strBody As String
dim mail as emailMessage
 
 dim SMTP_Provider, SMTP_User, SMTP_Pass, SMTP_From As string
dim SMTP_Port As Integer
 
SMTP_Provider = “” // This is your SMTP provider
SMTP_Port = 1025
SMTP_User = “”  // Your account at the SMTP provider
SMTP_Pass = “”  // Your password
SMTP_From = “” // Email from
 
// set up the socket
MailSocket.address = SMTP_Provider
MailSocket.port = SMTP_Port
MailSocket.username = SMTP_User
MailSocket.password = SMTP_Pass
 
// populate the email message
mail = new emailMessage
mail.fromAddress = SMTP_From
mail.subject = strSubject
mail.bodyPlainText = strBody

// add recipients
mail.addRecipient strTo

// send the email
MailSocket.messages.append mail
MailProgress.visible = true
MailSocket.sendMail
 

Hi Rick.

You don’t seem to understand the situation. Some SMTP servers use a protocol called STARTTLS. The client does not have a choice of not using it when the email server is using it.

The Xojo SMTP sockets will not work with those SMTP email servers because it was not fully developed to handle those SMTP email servers.

I’m guessing the Xojo engineer wasn’t aware of those types of SMTP email servers/protocol so I’m guessing it was overlooked.
That means if your email server or your client’s email server uses the STARTTLS protocol you cannot use the built in Xojo SMTP sockets. You need to code your own SMTP socket or purchase someone else’s which can handle the STARTTLS protocol.

http://en.wikipedia.org/wiki/STARTTLS

You are correct for email servers not using the STARTTLS protocol the Xojo SMTP sockets seem to work well and I use them.

I’m hoping Xojo fixes this soon.

You could try curl instead. e.g. our CURLSMBS class where we have examples for SMTP included.

Please something more simple for beginners or amateurs who could build an application of automated test for students which mails results to the teacher. With the server of my university I can send such mails via gmail smtp but not via University smtp, which doesn’t support “plain” authentication type, only login type.
Language reference says "SMTPSocket supports the ‘login’ authentication type as well as ‘plain.’ ", but…
Thanks