
Transcription
GSM SMTPSApplication NoteGSM/GPRS Module SeriesRev. GSM SMTPS Application Note V3.1Date: 2015-04-08www.quectel.com
GSM/GPRS Module SeriesGSM SMTPS Application NoteOur aim is to provide customers with timely and comprehensive service. For anyassistance, please contact our company headquarters:Quectel Wireless Solutions Co., Ltd.Office 501, Building 13, No.99, Tianzhou Road, Shanghai, China, 200233Tel: 86 21 5108 6236Mail: [email protected] our local office, for more information, please visit:letlcaeitunQ aspxFor technical support, to report documentation errors, please spxOr Email: [email protected] NOTESQUECTEL OFFERS THIS INFORMATION AS A SERVICE TO ITS CUSTOMERS. THE INFORMATIONPROVIDED IS BASED UPON CUSTOMERS’ REQUIREMENTS. QUECTEL MAKES EVERY EFFORTTO ENSURE THE QUALITY OF THE INFORMATION IT MAKES AVAILABLE. QUECTEL DOES NOTMAKE ANY WARRANTY AS TO THE INFORMATION CONTAINED HEREIN, AND DOES NOT ACCEPTANY LIABILITY FOR ANY INJURY, LOSS OR DAMAGE OF ANY KIND INCURRED BY USE OF ORRELIANCE UPON THE INFORMATION. ALL INFORMATION SUPPLIED HEREIN IS SUBJECT TOCHANGE WITHOUT PRIOR NOTICE.COPYRIGHTTHIS INFORMATION CONTAINED HERE IS PROPRIETARY TECHNICAL INFORMATION OFQUECTEL CO., LTD. TRANSMITTABLE, REPRODUCTION, DISSEMINATION AND EDITING OF THISDOCUMENT AS WELL AS UTILIZATION OF THIS CONTENTS ARE FORBIDDEN WITHOUTPERMISSION. OFFENDERS WILL BE HELD LIABLE FOR PAYMENT OF DAMAGES. ALL RIGHTSARE RESERVED IN THE EVENT OF A PATENT GRANT OR REGISTRATION OF A UTILITY MODELOR DESIGN.Copyright Quectel Wireless Solutions Co., Ltd. 2015. All rights reserved.GSM SMTPS Application NoteConfidential / Released1 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteAbout the DocumentHistoryRevision3.03.1letlcaeitunQ idefnoCDateAuthorDescription2013-09-25Andy CHENInitial2015-04-08Andy CHENAdded applicable modulesGSM SMTPS Application NoteConfidential / Released2 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteContentsAbout the Document . 2Contents . 3Table Index . 41Introduction . 51.1.SSL Version and CipherSuite. 51.2.The Usage of SMTP/SMTPS Function . 61.3.Evading Failure of Certificate Verification Due to RTC Time . 71.4.Error Handling . 71.4.1. PDP Activation Fails . 71.4.2. DNS Parse Fails. 81.4.3. Error Response of AT QSMTPPUT . 82Description of AT Command . 92.1.General Description. 92.2.AT Command Syntax . 92.2.1. AT QSSLCFG SSL Configuration. 93Example about the Usage of SMTP/SMTPS Function. 143.1.Send Email without SSL. 143.2.Send Email by SSL . 163.3.Send Email by STARTTLS . 194Summary of Error Code . 235Appendix A Reference. 25letlcaeitunQ idefnoCGSM SMTPS Application NoteConfidential / Released3 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteTable IndexTABLE 1: SSL VERSION . 5TABLE 2: SSL CIPHERSUITE. 5TABLE 3: SUMMARY OF ERROR CODES . 23TABLE 4: RELATED DOCUMENTS . 25TABLE 5: TERMS AND ABBREVIATIONS . 25letlcaeitunQ idefnoCGSM SMTPS Application NoteConfidential / Released4 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note1IntroductionThis document describes how to use the SMTPS function of Quectel standard module.In some cases, in order to ensure communication privacy, the communication between the server and theclient should be in an encrypted way. So that it can prevent the communication data from eavesdropping,tampering, or forging. The SSL function meets these demands.letlcaeitunQ idefnoCThis document is applicable to Quectel M10, M66, M85 and M95 modules.1.1. SSL Version and CipherSuiteSo far, several SSL versions have been released. They are SSL2.0, SSL3.0, TLS1.0, TLS1.1, and TLS1.2.The following versions are supported by Quectel modules.Table 1: SSL VersionSSL VersionSSL3.0TLS1.0TLS1.1TLS1.2The following table shows the names of the CipherSuites that Quectel module supports. Please refer toRFC 2246-The TLS Protocol Version 1.0 on the CipherSuite definitions for details.Table 2: SSL CipherSuiteCipherSuite CodeCipherSuite Name0X0035TLS RSA WITH AES 256 CBC SHAGSM SMTPS Application NoteConfidential / Released5 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note0X0005TLS RSA WITH RC4 128 SHA0X0004TLS RSA WITH RC4 128 MD50X000ATLS RSA WITH 3DES EDE CBC SHA0X002FTLS RSA WITH AES 128 CBC SHA0X003DTLS RSA WITH AES 256 CBC SHA256letlcaeitunQ idefnoC1.2. The Usage of SMTP/SMTPS FunctionThere are three kinds of connections between SMTP client and SMTP server, which are no SSL, SSL andSSL with STARTTLS. Some SMTP servers support only two kinds and some support all of them, you canchoose one kind according to your needs. The steps of the usage of SMTPS function are briefly listed asbelow.Step 1: The command “AT QICSGP” is used to configure the APN, username, password of the contextprofile, and so on.Step 2: The command “AT QIREGAPP” is used to register to the TCP/IP stack.Step 3: The command “AT QIACT” is used to activate GPRS PDP context. After PDP context isactivated, the command “AT QILOCIP” is used to query the local IP address.Step 4: The command “AT QSSLCFG” is used to configure SSL version, CipherSuite, connectionbetween SMTP client and SMTP server and so on.Step 5: Execute the command “AT QSMTPUSER” and “AT QSMTPPWD” to set the user name andpassword for authentication.1)2)3)Step 6:Step 7:Execute the command “AT QSMTPNAME” and “AT QSMTPADDR” to set the name and theemail address of the sender.The command “AT QSMTPSRV” is used to set the SMTP server and port. The command“AT QSMTPDST” is used to add or delete recipients.Execute the command “AT QSMTPSUB” and “AT QSMTPBODY” to edit the subject and thebody of the email. Execute the command “AT QSMTPATT” and “AT QSMTPDATT” to add ordelete an attachment for the email. The attachments can be RAM files or UFS files. It isstrongly recommended to use RAM file to upload the attachments.The command “AT QSMTPPUT” is used to send email.The command “AT QSMTPCLR” is used to clear all email configuration, “AT QFDEL” is usedto delete the files as attachments, and “AT QIDEACT” is used to deactivate GPRS PDPcontext.GSM SMTPS Application NoteConfidential / Released6 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note“AT QSMTPCLR” will clear the email configuration in Step 5. Of course, if you want to change the type ofSMTP server, the SMTP server address and user information, Step 4 to Step 5 can be repeated. If youhave not sent email for a long time, such as 30 minutes or even longer, you should deactivate the PDPcontext by AT QIDEACT.NOTES1.2.3.If you want to know the usage of AT commands QICSGP, QIACT, QILOCIP, QIMUX and QIDEACTfor details, please refer to Mxx AT Commands Manual. And please refer toGSM SMTP AT Command Manual V1.0.pdf on SMTP AT commands for more information.About the usage of QFDEL and other FILE AT commands, please refer to GSM FILE ATC Vx.x.For other AT commands, please refer to the corresponding documentation of the correspondingmodule.letlcaeitunQ idefnoC1.3. Evading Failure of Certificate Verification Due to RTC TimeIn the normal case, the RTC time of module must be within the period of validity of the certificate,otherwise the result of verifying certificate will be failure. In order to resolve this problem, the first methodis to set a proper time for the module via AT command “AT CCLK time ”. And the second one is toexecute AT command "AT QSSLCFG "ignorertctime",1", after configuring ignorertctime value as 1,module will ignore the period of validity of the certificate.NOTEIf you want to know detailed usage of AT commands CCLK, please refer to Mxx AT Commands Manual.1.4. Error Handling1.4.1. PDP Activation FailsIf you failed to activate PDP context by AT QIACT command, please check the following aspects:1.2.3.Query whether the PS domain is attached by AT CGATT? command, if not, execute AT CGATT 1 toattach PS domain.Query the CGREG status by AT CGREG? and make sure the PS domain is registered to.Query the PDP context parameters by AT QIREGAPP command, make sure the APN of specifiedPDP context is set.GSM SMTPS Application NoteConfidential / Released7 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note4.Make sure the specified PDP context ID is neither used by PPP nor activated by AT CGACTcommand.If the result of checking is OK, but the result of executing AT QIACT command always fails, please rebootthe module to resolve this issue. After booting the module, please check the terms mentioned above atleast three times and each time at an interval of 10 minutes to avoid frequently rebooting the module.1.4.2. DNS Parse FailsWhen executing AT QSMTPPUT commands, if it responds “ QSMTPPUT: -4”, please check followingaspects:1.2.letlcaeitunQ idefnoCMake sure the domain name of SMTP server is valid.Execute "AT QILOCIP", if it can acquire a valid IP address, it means that the PDP context isactivated successfully. Otherwise the PDP context is in a deactivate state.1.4.3. Error Response of AT QSMTPPUTAfter executing AT QSMTPPUT, “ QSMTPPUT: result ” will be returned to indicate the result of sendingmail, and result is an error code. If result is 0, it means it is successful to send the mail. If it is anegative numeric, it means sending mail is failed, please resend it.If result is not 0, it indicates the sending is failed, please resend it. If resending is not successful, youshould deactivate the PDP context by AT QIDEACT command, and try again. (Please refer to Chapter1.4.1.)If result is a negative numeric, you can refer to Chapter 4 to check the reason of this errorcode. Forexample, if result is -535 (Authentication failed), username or password may be wrong. If result is -530 (Access denied), you may send email too frequently and the SMTP server rejects to post email.For details, you can refer to the document RFC2821 (Simple Mail Transfer Protocol).GSM SMTPS Application NoteConfidential / Released8 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note2Description of AT Command2.1. General DescriptionletlcaeitunQ idefnoCTest CommandAT x ?This command returns the list of parameters and value rangesset by the corresponding Write Command or internal processes.Read CommandAT x ?This command returns the currently set value of the parameteror parameters.Write CommandAT x This command sets the user-definable parameter values.AT x This command reads non-variable parameters affected byinternal processes in the GSM engineExecutionCommand2.2. AT Command Syntax2.2.1. AT QSSLCFGSSL ConfigurationThis AT command is used to configure the SSL version, CipherSuite, secure level, CA certificate, clientcertificate, client key, ignoring RTC time, HTTP/HTTPS, and SMTP/SMTPS. These parameters will beused in the handshake procedure.CTX is the abbreviation of the SSL (Secure Socket Layer) context. ctxindex is the index of the SSLcontext. Quectel standard module supports 6 SSL contexts at most. On the basis of a SSL context,several SSL connections can be established. The settings such as the SSL version and the CipherSuiteare stored in the SSL context, and the settings will be applied to the new SSL connection which isassociated with the SSL context.AT QSSLCFGSSL ConfigurationTest CommandAT QSSLCFG ?Response QSSLCFG: “type”,(0-5),“value”OKQuery the setting of the contextGSM SMTPS Application Note QSSLCFG: ctxindex , sslversion , seclevel ,Confidential / Released9 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteAT QSSLCFG “ctxindex”, ctxindex ciphersuite , cacert , clientcertname , clientkeyname OKOtherwise responseERRORConfigure the SSL versionAT QSSLCFG “sslversion”, ctxindex [, sslversion ]ResponseOKOtherwise responseERRORIf the third parameter is omitted, query the “sslversion” value. QSSLCFG: “sslversion”, sslversion letlcaeitunQ idefnoCOKConfigure the CipherSuiteAT QSSLCFG “ciphersuite”, ctxindex [, listofsupported ciphersuite s ]ResponseOKOtherwise responseERRORIf the third parameter is omitted, query the “ciphersuite” value. QSSLCFG: “ciphersuite”, ciphersuite OKConfigure the authentication modeAT QSSLCFG “seclevel”, ctxindex [, seclevel ]ResponseOKOtherwise responseERRORIf the third parameter is omitted, query the “seclevel” value. QSSLCFG: “seclevel”, seclevel OKConfigure the path of root certificateAT QSSLCFG “cacert”, ctxindex [, cacertname ]ResponseOKOtherwise responseERRORIf the third parameter is omitted, query the “cacertname”value. QSSLCFG: “cacert”, cacertname OKConfigure the path of client certificateAT QSSLCFG “clientcert”, ctxindex [, clientcertname ]GSM SMTPS Application NoteResponseOKOtherwise responseERRORConfidential / Released10 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteIf the third parameter is omitted, query the “clientcertname”value. QSSLCFG: “clientcert”, clientcertname OKConfigure the path of client keyAT QSSLCFG “clientkey”, ctxindex [, clientkeyname ]ResponseOKOtherwise responseERRORIf the third parameter is omitted, query the “clientkeyname”value. QSSLCFG: “clientkey”, clientkeyname letlcaeitunQ idefnoCOKConfigure whether to ignore the RTCtimeAT QSSLCFG “ignorertctime”[, ignorertctime ]ResponseOKOtherwise responseERRORIf the second parameter is omitted, query the “ignorertctime”value. QSSLCFG: “ignorertctime”, ignorertctime OKEnable/Disable the HTTPS functionAT QSSLCFG “https”[, httpsenable ]ResponseOKOtherwise responseERRORIf the second parameter is omitted, query the “httpsenable”value. QSSLCFG: “https”, httpsenable OKConfigure the SSL context index forHTTPSAT QSSLCFG “httpsctxi”[, httpsctxindex ]ResponseOKOtherwise responseERRORIf the second parameter is omitted, query the “httpsctxindex”value. QSSLCFG: “httpsctxi”, httpsctxindex OKConfigure the type of SMTP/SMTPSAT QSSLCFG “smtpstyle”[, smtpstyle ]GSM SMTPS Application NoteResponseOKOtherwise responseConfidential / Released11 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteERRORIf the second parameter is omitted, query the “smtpstyle”value. QSSLCFG: “smtpstyle”, smtpstyle OKConfigure the SSL context index forSMTPSAT QSSLCFG “smtpsctxi”[, smtpsctxindex ]ResponseOKOtherwise responseERRORIf the second parameter is omitted, query the “smtpsctxindex”value. QSSLCFG: “smtpctxi”, smtpsctxindex letlcaeitunQ idefnoCOKReferenceParameter ctxindex sslversion ciphersuite seclevel cacertname SSL context index0 5Configure the SSL version0SSL3.01TLS1.02TLS1.13TLS1.24ALL SUPPORTConfigure the CipherSuite0X0035 TLS RSA WITH AES 256 CBC SHA0X002F TLS RSA WITH AES 128 CBC SHA0X0005 TLS RSA WITH RC4 128 SHA0X0004 TLS RSA WITH RC4 128 MD50X000A TLS RSA WITH 3DES EDE CBC SHA0X003D TLS RSA WITH AES 256 CBC SHA2560XFFFF All supportConfigure the authentication mode0No authentication1Manage server authentication2Manage server and client authentication if requested by the remoteserver.If no authentication is set, no security data are needed(Client certificate, Server CA certificate and Client private key).String format, configure the server CA certificateGSM SMTPS Application NoteConfidential / Released12 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note clientcertname clientkeyname ignorertctime httpsenable httpsctxindex smtpstyle String format, configure the client certificateString format, configure the client keyConfigure whether ignore the RTC time0Do not ignore the RTC time1Ignore the RTC timeEnable/disable the HTTPS function0Disable HTTPS1Enable HTTPSConfigure the SSL context for HTTPSHttpsctxindex is the index of SSL context. If the host does not configure thehttpsctxindex, the value of httpsctxindex will be -1.0-5Configure the type of SMTP/SMTPS0No SSL1SSL2SSL with STARTTLSConfigure the SSL context for SMTPSsmtpsctxindex is the index of SSL context. If the host does not configure thesmtpsctxindex, the value of smtpsctxindex will be -1.0-5letlcaeitunQ idefnoC smtpsctxindex GSM SMTPS Application NoteConfidential / Released13 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note3Example about the Usage of SMTP/SMTPS FunctionletlcaeitunQ idefnoC3.1. Send Email without SSL//Step 1: Configure and activate the PDP context.AT QIFGCNT 0OKAT QICSGP 1,“CMNET”OKAT QIREGAPPOKAT QIACTOKAT QILOCIP10.1.83.188//Set context 0 as foreground context.//Set bearer type as GPRS and the APN is “CMNET”and no user name and password for the APN.//Register to the TCP/IP stack.//Activate GPRS PDP context.//Query the local IP address.//Step 2: Configure SMTP server without SSL.AT QSSLCFG “smtpstyle”,0OK//The type is No SSL mode.//Step 3: Configure user account and recipients.AT QSMTPUSER "quectel [email protected]"OK//Set the user name for authentication.AT QSMTPPWD "aol123456***"//Set the password for authentication.OKAT QSMTPNAME "quectel company"//Set the name of the sender.OKAT QSMTPADDR "quectel [email protected] "//Set the email address of the sender.OKAT QSMTPSRV "smtp.aol.com",25//Set the SMTP server and port.OKAT QSMTPDST 1,1,“quectel [email protected]” //Add a recipient and the recipient type is 1 whichmeans recipients.GSM SMTPS Application NoteConfidential / Released14 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteOK QSMTPDST: 0AT QSMTPDST 1,2,“quectel [email protected]” //Add a recipient and the recipient type is 2 whichmeans CC recipients.OK QSMTPDST: 0AT QSMTPDST 1,3,“quectel [email protected]”//Add a recipient and the recipient type is 3 whichmeans BCC recipients.OK QSMTPDST: 0letlcaeitunQ idefnoC//Step 4: Edit the email content.AT QSMTPSUB 0,"about smtp e-mail"OKAT QSMTPBODY 1,60OKCONNECT//For example, input 14 bytes: Hello, welcome! QSMTPBODY: 14AT QFUPL “RAM:pic.jpg”,30000CONNECT//Upload a file to RAM, the file will be saved as“file test.txt” and the maximum of the size is 30000bytes. (If you want to know more information aboutAT command “AT QFUPL, AT QFDEL”, please referto documents GSM FILE ATC XXX.pdf). Input the data of the picture, the size is 26977 bytes, and input “ ” to finish inputting data QFUPL: 26977,cea0OKAT QFUPL “RAM: file test.txt”,100CONNECT Input the data of the file test.txt, the size is 100 bytes QFUPL: 100,7159OKAT QSMTPATT “RAM:pic.jpg”OKGSM SMTPS Application Note//Add an attachment for the email, pic.jpg is in RAM.Confidential / Released15 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note QSMTPATT: 26977AT QSMTPATT “RAM:file test.txt”//Add an attachment for the email, file test.txt is inRAM.OK QSMTPATT: 100AT QSMTPATT? QSMTPATT: 1, “RAM:pic.jpg”,26977 QSMTPATT: 2, “RAM:file test.txt”,100OKletlcaeitunQ idefnoC//Step 5: Send email.AT QSMTPPUT 800OK//Send email and the maximum time is 800 seconds.//It may take a few minutes. QSMTPPUT: 0//Send mail successfully.//If the host sends mail unsuccessfully, it is no need to do any configuration settings, the host can execute“AT QSMTPPUT 800” directly to send mail again.//Step 6: Clear all of email configuration; delete attachment and deactivate PDP context.AT QSMTPCLROKAT QFDEL “RAM:pic.jpg”OKAT QFDEL “RAM:file test.txt”OK//Clear the configuration from step 3 to step 4.//Delete the pic.jpg from RAM.//Delete the file test.txt from RAM.//If the host wants to send a new email, repeat from step 3 to step 6.AT QIDEACTDEACT OK//Deactivate GPRS PDP context.3.2. Send Email by SSL//Step 1: Configure and activate the PDP context.AT QIFGCNT 0OKAT QICSGP 1,“CMNET”//Set context 0 as foreground context.//Set bearer type as GPRS and the APN is “CMNET”and no user name and password for the APN.OKGSM SMTPS Application NoteConfidential / Released16 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteAT QIREGAPPOKAT QIACTOKAT QILOCIP10.1.83.188//Register to the TCP/IP stack.//Activate GPRS PDP context.//Query the local IP address.//Step 2: Configure SSL for SMTPSAT QSSLCFG “sslversion”,0,1OKAT QSSLCFG “seclevel",0,0OKAT QSSLCFG “ciphersuite”,0,”0XFFFF”letlcaeitunQ idefnoCOKAT QSSLCFG “smtpstyle”,1OKAT QSSLCFG “smtpsctxi”,0OKAT QSSLCFG “smtpstyle” QSSLCFG: “smtpstyle”,1OKAT QSSLCFG “smtpsctxi” QSSLCFG: “smtpsctxi”,0OK//Configure SslVersion.//Configure no authentication mode.//Configure SSL CipherSuite type as 0XFFFF whichmeans support all CipherSuite.//The type is SSL mode.//Select SSL context 0 for SMTPS.//Query the SMTP type.//Query the index of SSL context.//Step 3: Configure SMTP server, user account and recipientsAT QSMTPUSER "[email protected]" //Set the user name for authentication.OKAT QSMTPPWD "yy1234***"//Set the password for authentication.OKAT QSMTPNAME "quectel company"//Set the name of the sender.OKAT QSMTPADDR "[email protected]" //Set the email address of the sender.OKAT QSMTPSRV "smtp.gmail.com",465//Set the SMTPS server and port.OKAT QSMTPDST 1,1,“quectel [email protected]” //Add a recipient and the recipient type is 1 whichOKmeans recipients.GSM SMTPS Application NoteConfidential / Released17 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note QSMTPDST: 0AT QSMTPDST 1,2,“quectel [email protected]” //Add a recipient and the recipient type is 2 whichmeans CC recipients.OK QSMTPDST: 0AT QSMTPDST 1,3,“quectel [email protected]”//Add a recipient and the recipient type is 3 whichmeans BCC recipients.OK QSMTPDST: 0letlcaeitunQ idefnoC//Step 4: Edit the email content.AT QSMTPSUB 0,"about smtps e-mail"OKAT QSMTPBODY 1,60OKCONNECT//For example, input 14 bytes: Hello, welcome! QSMTPBODY: 14AT QFUPL “RAM:pic.jpg”,30000CONNECT//Upload a file to RAM, the file will be saved as“file test.txt” and the maximum of the size is 30000bytes.(If you want to know more information aboutAT command “AT QFUPL, AT QFDEL”, pleaserefer to documents GSM FILE ATC XXX.pdf). Input the data of the picture, the size is 26977 bytes, and input “ ” to finish inputting data QFUPL: 26977,cea0OKAT QFUPL “RAM: file test.txt”,100CONNECT Input the data of the file test.txt, the size is 100 bytes QFUPL: 100,7159OKAT QSMTPATT “RAM:pic.jpg”//Add an attachment for the email, pic.jpg is in RAM.OKGSM SMTPS Application NoteConfidential / Released18 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note QSMTPATT: 26977AT QSMTPATT “RAM:file test.txt”//Add an attachment for the email, file test.txt is inRAM.OK QSMTPATT: 100AT QSMTPATT? QSMTPATT: 1,“RAM:pic.jpg”,26977 QSMTPATT: 2,“RAM:file test.txt”,100OKletlcaeitunQ idefnoC//Step 5: Send email.AT QSMTPPUT 800OK//Send email and the maximum time is 800 seconds.//It may take a few minutes. QSMTPPUT: 0//Send mail successfully.//If the host sends mail unsuccessfully, it is no need to do any configuration settings. The host can execute“AT QSMTPPUT 800” directly to send mail again.//Step 6: Clear all of email configuration; delete attachment and deactivate PDP context.AT QSMTPCLROKAT QFDEL “RAM:pic.jpg”OKAT QFDEL “RAM:file test.txt”OK//Clear the configuration from step 3 to step 4.//Delete the pic.jpg from RAM.//Delete the file test.txt from RAM.//If the host wants to send a new email, repeat from step 3 to step 6.AT QIDEACTDEACT OK//Deactivate GPRS PDP context.3.3. Send Email by STARTTLS//Step 1: Configure and activate the PDP context.AT QIFGCNT 0OKAT QICSGP 1, “CMNET”GSM SMTPS Application Note//Set context 0 as foreground context.//Set bearer type as GPRS and the APN is “CMNET”and no user name and password for the APN.Confidential / Released19 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteOKAT QIREGAPPOK//Register the TCP/IP stack.AT QIACTOKAT QILOCIP10.1.83.188//Activate GPRS PDP context.//Query the local IP address.//Step 2: Configure SSL for SMTPSAT QSSLCFG “sslversion”,0,1OKAT QSSLCFG “seclevel",0,0OKAT QSSLCFG “ciphersuite”,0,”0XFFFF”OKAT QSSLCFG “smtpstyle”,2OKAT QSSLCFG “smtpsctxi”,0OKAT QSSLCFG “smtpstyle” QSSLCFG: “smtpstyle”,2letlcaeitunQ idefnoCOKAT QSSLCFG “smtpsctxi” QSSLCFG: “smtpsctxi”,0OK//Configure SSL Version.//Configure no authentication mode.//Configure SSL CipherSuite type as 0XFFFF whichmeans support all CipherSuite.//The type is STARTTLS mode.//Select SSL context 0 for SMTPS.//Query the SMTP type.//Query the index of SSL context.//Step 3: Configure SMTP server, user account and recipients.AT QSMTPUSER "quectel [email protected]" //Set the user name for authentication.OKAT QSMTPPWD "abc1234***"//Set the password for authentication.OKAT QSMTPNAME "quectel company"//Set the name of the sender.OKAT QSMTPADDR "quectel [email protected]" //Set the email address of the senderOKAT QSMTPSRV "smtp.live.com",25//Set the SMTPS server and mail port.OKAT QSMTPDST 1,1,“quectel [email protected]” //Add a recipient and the recipient type is 1 whichOKmeans recipients. QSMTPDST: 0GSM SMTPS Application NoteConfidential / Released20 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteAT QSMTPDST 1,2,“quectel [email protected]” //Add a recipient and the recipient type is 2 whichmeans CC recipients.OK QSMTPDST: 0AT QSMTPDST 1,3,“quectel [email protected]”//Add a recipient and the recipient type is 3 whichmeans BCC recipients.OK QSMTPDST: 0//Step 4: Edit the email content.letlcaeitunQ idefnoCAT QSMTPSUB 0,"about smtps starttls e-mail"OKAT QSMTPBODY 1,60OKCONNECT QSMTPBODY: 14AT QFUPL “RAM:pic.jpg”,30000CONNECT//For example, input 14 bytesHello, welcome!//Upload a file to RAM,the file will be saved as“file test.txt” and the maximum of the size is30000 bytes.(If you want to know more informationabout AT command “AT QFUPL, AT QFDEL”,pleaserefertodocumentsGSM FILE ATC XXX.pdf). Input the data of the picture, the size is 26977 bytes, and input “ ” to finish inputting data QFUPL: 26977,cea0OKAT QFUPL “RAM: file test.txt”,100CONNECT Input the data of the file test.txt, the size is 100 bytes QFUPL: 100,7159OKAT QSMTPATT “RAM:pic.jpg”OK//Add an attachment for the email, pic.jpg is in RAM. QSMTPATT: 26977GSM SMTPS Application NoteConfidential / Released21 / 25
GSM/GPRS Module SeriesGSM SMTPS Application NoteAT QSMTPATT “RAM:file test.txt”//Add an attachment for the email, file test.txt is inRAM.OK QSMTPATT: 100AT QSMTPATT? QSMTPATT: 1,“RAM:pic.jpg”,26977 QSMTPATT: 2,“RAM:file test.txt”,100OK//Step 5: Send email.letlcaeitunQ idefnoCAT QSMTPPUT 800OK//Send email and the maximum time is 800 seconds.//It may take a few minutes. QSMTPPUT: 0//Send mail successfully.//If the host sends mail unsuccessfully, it is no need to do any configuration settings, the host can execute“AT QSMTPPUT 800” directly to send mail again.//Step 6: Clear all of email configuration; delete attachment and deactivate PDP context.AT QSMTPCLROKAT QFDEL “RAM:pic.jpg”OKAT QFDEL “RAM:file test.txt”OK//Clear the configuration from step 3 to step 4.//Delete the pic.jpg from RAM.//Delete the file test.txt from RAM.//If the host wants to send a new email, repeat from step 3 to step 6.AT QIDEACTDEACT OKGSM SMTPS Application Note//Deactivate GPRS PDP context.Confidential / Released22 / 25
GSM/GPRS Module SeriesGSM SMTPS Application Note4Summary of Error CodeThe error code errorcode indicates an error related to mobile equipment or network. The detail about errorcode is described in the following table.letlcaeitunQ idefnoCTable 3: Summary of Error ngUnknown errorThe SMTP service is busy. Such as, downloading body or attachment, sending emailFailed to get IP address according to domain nameNetwork error. Such as, failed to activate GPRS/CSD context, failed to establish theTCP connection with the SMTP server or failed to send ema
1.2. The Usage of SMTP/SMTPS Function There are three kinds of connections between SMTP client and SMTP server, which are no SSL, SSL and SSL with STARTTLS. Some SMTP servers support only two kinds and some support all of them, you can choose one kind according to your needs. The steps of the usage of SMTPS function are briefly listed as below.