SoFunction
Updated on 2025-04-13

Explanation on how to write letters in Yi Language

As we all know, the Easy Language Support Library comes with the command "Connect the sending server()" and "Distributed development server()"...

However, after practical application, there are unstable factors in connection and disconnection. The reason is not known yet. This will cause the 25 port of the sending message to be occupied and stuck, and eventually cut off all network connections.

After reviewing the information, we came up with another way of sending a message. The principle is to use customer components to connect to the SMTP server, judge the return value step by step and send data. For details, please refer to the source code!

.Version 2
.Support library shell
.Support library spec

.Subprogram Send email notification
.parameter Topic content, Text type
.Local variables Return data, Text type

client1.connect (smtp, 25)
Return data = To text (Waiting for data ())
.If true (Take the left side of the text (Return data, 3) ≠ “220”)
  disconnect ()
  Information box (“Send failed”, 0, )
  return ()
.If true结束
Send characters (“EHLO ” + smtp + #line newline)' Server addressReturn data = To text (Waiting for data ())
.If true (Take the left side of the text (Return data, 3) ≠ “250”)
  disconnect ()
  Information box (“Send failed”, 0, )
  return ()
.If true结束
Send characters (“auth login” + #line newline)Return data = To text (Waiting for data ())
.If true (Take the left side of the text (Return data, 3) ≠ “334”)
  disconnect ()
  Information box (“Send failed”, 0, )
  return ()
.If true结束
Send characters (BASE64coding (To byte set (id)) + #line break) ' Email accountReturn data = To text (Waiting for data ())
.If true (Take the left side of the text (Return data, 3) ≠ “334”)
  disconnect ()
  Information box (“Send failed”, 0, )
  return ()
.If true结束
Send characters (BASE64coding (To byte set (password)) + #line newline)' PasswordReturn data = To text (Waiting for data ())
.If true (Take the left side of the text (Return data, 3) ≠ “235”)
  disconnect ()
  Information box (“Send failed”, 0, )
  return ()
.If true结束
Send characters (“MAIL FROM: ” + “<” + id + “>” + #line break) ' SenderReturn data = To text (Waiting for data ())
.If true (Take the left side of the text (Return data, 3) ≠ “250”)
  disconnect ()
  Information box (“Send failed”, 0, )
  return ()
.If true结束
Send characters (“RCPT TO: ” + “<” + email + “>” + #line break) ' RecipientReturn data = To text (Waiting for data ())
.If true (Take the left side of the text (Return data, 3) ≠ “250”)
  disconnect ()
  Information box (“Send failed”, 0, )
  return ()
.If true结束
Send characters (“DATA” + #line newline)Return data = To text (Waiting for data ())
.If true (Take the left side of the text (Return data, 3) ≠ “354”)
  disconnect ()
  Information box (“Send failed”, 0, )
  return ()
.If true结束
Send characters (“Subject: ” + Topic content + #line breaks) ' topicSend characters (“From:” + “<” + id + “>” + #line newline)Send characters (“To:” + “<” + email + “>” + #line newline)Send characters (#line newline)Send characters (Topic content + #line break) ' textSend characters (#Line breaks + “.” + #line newline)Return data = To text (Waiting for data ())
.If true (Take the left side of the text (Return data, 3) ≠ “250”)
  Information box (“Send failed”, 0, )
.If true结束
disconnect ()


.Subprogram _client1_Data Arrival

data = client1.取回data ()

.Subprogram Waiting for data, Byte set
.Local variables data_, Byte set

.Cycle judgment first ()
  Handle events ()
.Cycle judgment tail (data = { })
data_ = data
data = { }
Debug output (To text (data_))
return (data_)

.Subprogram _client1_connectdisconnect

Debug output (“connectdisconnect” + #line newline)
.Subprogram Send characters
.parameter character, Text type
.Local variables i, Integer type

Debug output (character)
.Cycle first (Take text length (character), i)
  client1.发送data (To byte set (character (Get the code (character, i))))
.Calculate the cycle ()

.Subprogram disconnect

Send characters (“quit” + #line newline)client1.disconnectconnect ()

.Subprogram BASE64coding, Text type
.parameter 待codingdata, Byte set, , 待codingByte set
.Local variables Remaining number
.Local variables temporary, Byte type, , "3"
.Local variables variable
.Local variables gather, Byte set
.Local variables length, Integer type
.Local variables character, Byte set
.Local variables i

length = 取Byte setlength (待codingdata)
.If true (length < 1)
  return (“”)
.If true结束
Remaining number = length % 3
.If true (Remaining number > 0)
  待codingdata = 待codingdata + 取空白Byte set (3 - Remaining number)
.If true结束
length = 取Byte setlength (待codingdata)
character = 取空白Byte set (length × 4 ÷ 3)
i = 1
gather = To byte set (“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/”)
.variable循环首 (1, length, 3, variable)
  temporary [1] = 待codingdata [variable]
  temporary [2] = 待codingdata [variable + 1]
  temporary [3] = 待codingdata [variable + 2]
  character [i] = gather [Move right (temporary [1], 2) + 1]
  character [i + 1] = gather [Move left (bit and (temporary [1], 3), 4) + Move right (temporary [2], 4) + 1]
  character [i + 2] = gather [Move left (bit and (temporary [2], 15), 2) + Move right (temporary [3], 6) + 1]
  character [i + 3] = gather [bit and (temporary [3], 63) + 1]
  i = i + 4
.variable循环尾 ()
.If true (Remaining number > 0)
  length = 取Byte setlength (character)
  .if (Remaining number = 1)
    character [length - 1] = Get the code (“=”, )
    character [length] = Get the code (“=”, )
  .otherwise
    character [length] = Get the code (“=”, )
  .if结束

.If true结束
return (To text (character))

The above is all the content we have compiled about the writing of sending letters. Thank you for your support.