Author Topic: SendEMAIL using SIM-5320 (3G) SOLVED  (Read 11426 times)

0 Members and 1 Guest are viewing this topic.

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
SendEMAIL using SIM-5320 (3G) SOLVED
« on: August 17, 2016, 06:07:22 am »
Trying to use current SIMCOM 5320 modem to end email...
Sooo close, but no prize - yet.

Unfortunately, it's a bit different to the SIM900, as it implements a newer version of the AT command set.

Is there anyone here that can help, or has experience in what I'm missing?
Should I revert to the 'old' AT email commands - or will they become extinct within my lifetime!?

The reference says the command sequence used below initiates the session, and sends the message - but I'm suspicious that the IP bearer is not being created - but can't find any other thoughts - so 'maybe it does' but my email message ain't going through !

Quote
Tried both with and without +CGATT and +CGDCONT placed before email commands

OPEN IP BEARER
AT+CGATT=1
OPEN PDP CONTEXT
AT+CGDCONT=1, "IP", "", "0.0.0.0", 0, 0

Tried with both AUTHENTICATED and NON-AUTHENTICATED servers
Also tried different servers and ports...

==================================================
NON-AUTHENTICATED SERVER
FIRST ATTEMPT
>send_test
AT+CSMTPSSRV="smtp-relay.gmail.com", 25, 1    <<=========
AT+CSMTPSAUTH=0    <<=========
AT+CSMTPSFROM="a_user@gmail.com"
AT+CSMTPSRCPT=0,0,"b_user@gmail.com", "Test Recipient"
AT+CSMTPSSUB=11
Test report
AT+CSMTPSBODY=64
Site test report
Test message body
on multiple lines
Mo 12:33
Sent
Completed OK  <<========= but nothing was sent

==================================================
SECOND ATTEMPT
>send_test
AT+CSMTPSSRV="smtp-relay.gmail.com", 25, 1    <<=========
AT+CSMTPSAUTH=1, "authuser", "authpwd"   <<=========
AT+CSMTPSFROM="a_user@gmail.com"
AT+CSMTPSRCPT=0,0,"b_user@gmail.com", "Test Recipient"
AT+CSMTPSSUB=11
Test report
AT+CSMTPSBODY=64
Site test report
Test message body
on multiple lines
Mo 12:33
FAILED    <<========= obviously nothing was sent

« Last Edit: August 30, 2016, 10:02:01 am by SL4P »
Don't ask a question if you aren't willing to listen to the answer.
 

Offline hendorog

  • Super Contributor
  • ***
  • Posts: 1617
  • Country: nz
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #1 on: August 17, 2016, 06:32:10 am »
The manual https://cdn-shop.adafruit.com/datasheets/SIMCOM_SIM5320_ATC_EN_V2.02.pdf
seems to say you are missing this command:
Code: [Select]
AT+SMTPSEND

It also says the error response from the body is normal when the process of sending the body is ongoing. Just guessing that sending the body just passes the body to the SMTP server and to actually send it you need to use the command above.

Worth a try anyway...
 

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #2 on: August 17, 2016, 06:42:55 am »
Yeah, sorry..., that's not shown, but is happening down the bottom after the 'day and time' - before the SENT or FAILED outcome.
Those response messages are returned from the OK string.

Basically, everything throws 'OK', all the way down - including +CSMTPSSEND on the first pass...
Which makes me think the 'send' is working, but the modem is sitting on the message - hence the second attempt fails (until a power cycle is completed)
Thanks for looking!
« Last Edit: August 17, 2016, 06:48:06 am by SL4P »
Don't ask a question if you aren't willing to listen to the answer.
 

Offline hendorog

  • Super Contributor
  • ***
  • Posts: 1617
  • Country: nz
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #3 on: August 17, 2016, 06:52:32 am »
Have you got another SMTP server to test against? Then you can watch the traffic using wireshark or something similar as well as seeing what the server thinks of the conversation.
 

Offline hendorog

  • Super Contributor
  • ***
  • Posts: 1617
  • Country: nz
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #4 on: August 17, 2016, 06:55:49 am »
Also for the auth case I think you want this:
Code: [Select]
AT+CSMTPSSRV="smtp-relay.gmail.com", 587, 2

Source: https://support.google.com/a/answer/2956491?hl=en
 

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #5 on: August 17, 2016, 07:14:20 am »
Also for the auth case I think you want this:
Code: [Select]
AT+CSMTPSSRV="smtp-relay.gmail.com", 587, 2
Source: https://support.google.com/a/answer/2956491?hl=en
Tried these as ssugested...
Quote
AT+CSMTPSSRV="smtp-relay.google.com", 587, 2
AT+CSMTPSAUTH=0
Thanks for the thought - same results... first one 'succeeds', second attempt 'fails' - but no email is sent... sigh
Don't ask a question if you aren't willing to listen to the answer.
 

Offline hendorog

  • Super Contributor
  • ***
  • Posts: 1617
  • Country: nz
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #6 on: August 17, 2016, 07:17:46 am »
Damn, what about this one:
Code: [Select]
AT+CSMTPSSRV="smtp-relay.gmail.com", 587, 2
AT+CSMTPSAUTH=1, "authuser", "authpwd"
 

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #7 on: August 17, 2016, 07:24:26 am »
Damn, what about this one:
Code: [Select]
AT+CSMTPSSRV="smtp-relay.gmail.com", 587, 2
AT+CSMTPSAUTH=1, "authuser", "authpwd"
Sadly not yet...
Don't ask a question if you aren't willing to listen to the answer.
 

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #8 on: August 17, 2016, 07:46:52 am »
Aha!
I looked a little deeper into the response messages, and found a result code :::
+CSMTPSSEND: 8
This indicates a 'Network error'

- yet the modem sends and receives voice / sms, and during registration reports
SIM: READY
REGISTERED
YES OPTUS
WCDMA IMT 2000 HSDPA

sometimes I get WCDMA 900, but that's neither here nor there.
HSDPA is the data channel - registered...
So I now have to search & read a bit more...  grateful for any more ideas!
Don't ask a question if you aren't willing to listen to the answer.
 

Offline hendorog

  • Super Contributor
  • ***
  • Posts: 1617
  • Country: nz
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #9 on: August 17, 2016, 07:54:42 am »
Ah, maybe you need to setup an APN to get internet access? Just like on a mobile phone.

 

Offline hendorog

  • Super Contributor
  • ***
  • Posts: 1617
  • Country: nz
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #10 on: August 17, 2016, 08:03:46 am »
Optus page says the APN should be "internet"
http://www.optus.com.au/shop/support/answer/our-mobile-phone-apns-technical-settings?requestType=NormalRequest&id=1378&typeId=5

i.e.
Code: [Select]
AT+CGDCONT=1, "IP", "internet", "0.0.0.0", 0, 0
 

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #11 on: August 17, 2016, 08:08:34 am »
I had tested that about 2 minutes before you replied!
Here's the latest result
Quote
AT+CGDCONT=1, "IP", "internet", "0.0.0.0", 0, 0
AT+CSMTPSSRV="smtp-relay.google.com", 587, 2
AT+CSMTPSAUTH=1, "xxxx", "11234565"
AT+CSMTPSFROM="a-user@gmail.com"
AT+CSMTPSRCPT=0,0,"b-user@gmail.com", "Controller Report"
AT+CSMTPSSUB=18
Controller report
AT+CSMTPSBODY=58
email test
Test message body
on multiple lines
We 18:02
FAILED >+CSMTPSSEND: 255  <===== UNKNOWN ERROR
Don't ask a question if you aren't willing to listen to the answer.
 

Offline hendorog

  • Super Contributor
  • ***
  • Posts: 1617
  • Country: nz
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #12 on: August 17, 2016, 08:35:16 am »
Ha :)

Here are some more ideas, mostly just guessing tho:

Activate and attach the PDP context:
Code: [Select]
AT+CGATT=1
AT+CGDCONT=1, "IP", "internet","0.0.0.0",0,0
AT+CGACT=1

Maybe try without auth again, but on port 587. Port 25 is sometimes blocked on certain networks.
TLS can be painful, so worth trying without that.
Code: [Select]
AT+CSMTPSSRV="smtp-relay.google.com", 587, 1
AT+CSMTPSAUTH=0

Also maybe try this command to clear the settings first:
Code: [Select]
AT+CSMTPSCLEAN

Also thought to see if you can leave some of the not needed bearer settings out:
Code: [Select]
AT+CGDCONT=1, "IP", "internet"
or
AT+CGDCONT=1, "IP", "internet",,,

 

Offline hendorog

  • Super Contributor
  • ***
  • Posts: 1617
  • Country: nz
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #13 on: August 17, 2016, 09:04:01 am »
Ah, it looks like a typo has crept into the server name during the process

it should be:
smtp-relay.gmail.com
not
smtp-relay.google.com

Couple more tests you could try:

DNS test:
Code: [Select]
AT+CDNSGIP="smtp-relay.gmail.com"

Ping:
Code: [Select]
AT+CPING="smtp-relay.gmail.com",1
 

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #14 on: August 17, 2016, 01:38:44 pm »
Thanks - yes the google/gmail was the victim of some swappin & cutting & pasting!!!
But my problem runs deeper...

POWER ON - FIRST attempt
Quote
AT+CGATT=1 OK
AT+CGDCONT=1, "IP", "internet", "0.0.0.0"
AT+CGACT=1, 1 OK
AT+CGPADDR=1 >> +CGPADDR: 1,"10.146.53.134"  <<==  ADDED TO SEE DHCP ADDRESS
AT+CSMTPSSRV="smtp.optusnet.com.au", 465, 2
AT+CSMTPSAUTH=0
AT+CSMTPSFROM="a_user@gmail.com"
AT+CSMTPSRCPT=0,0,"b_user@gmail.com", "Controller Report"
AT+CSMTPSSUB=17
   Controller Report
AT+CSMTPSBODY=62
   internode test
   Test message body
   on multiple lines
   We 22:50
OK
>
+CSMTPSSEND: 8  <<== NETWORK ERROR

Immediately after - make SECOND attempt
Quote
AT+CGATT=1 OK
AT+CGDCONT=1, "IP", "internet", "0.0.0.0"
AT+CGACT=1, 1 OK
AT+CGPADDR=1 >> +CGPADDR: 1,"0.0.0.0"  <<==  IP ADDRESS HAS GONE ??!
AT+CSMTPSSRV="smtp.optusnet.com.au", 465, 2
AT+CSMTPSAUTH=0
AT+CSMTPSFROM="a_user@gmail.com"
AT+CSMTPSRCPT=0,0,"b_user@gmail.com", "Controller Report"
AT+CSMTPSSUB=17
   ControlMate Report
AT+CSMTPSBODY=62
   internode test
   Test message body
   on multiple lines
   We 22:53
+CSMTPSSEND: 255  <<== UNKNOWN ERROR
>

Note the IP address has gone on the second attempt!
I didn't drop the connection
I tried with optus and gmail servers - same result

Finally power cycle - then a THIRD attempt - result identical to the FIRST
Which makes me think the modem is receiving all the commands - and getting into 'a mode' where it won't accept another 'send' until the previous one is sent, or the modem is power cycled (clearing the operational states)

http://www.edaboard.com/thread125473.html seems to suggest we're doing the right stuff...
The lost IP address may occur because I'm establishing the connection 'again' - but I don't think so.
« Last Edit: August 17, 2016, 01:41:05 pm by SL4P »
Don't ask a question if you aren't willing to listen to the answer.
 

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #15 on: August 19, 2016, 12:12:01 am »
More info:
After the initial data connection, the modem LED flashed rapidly - indicating 'data mode'

Adding +CGATT=0 and +CGACT=0,1  to disable the data context after the send, released the modem from data mode - and the mode/LED returned to 'non-data mode.

Still no success sending email tho', and 255 error persists
Don't ask a question if you aren't willing to listen to the answer.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8270
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #16 on: August 19, 2016, 02:10:55 am »
Have you got another SMTP server to test against? Then you can watch the traffic using wireshark or something similar as well as seeing what the server thinks of the conversation.
Seconding this advice. Even just netcat listening on a random port would be sufficient, provided your ISP isn't those "not quite full Internet" ones who don't give you a publicly routable IP. You will at least get an idea of whether it even manages to make a connection to the server.
 

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #17 on: August 19, 2016, 02:20:07 am »
The challenge is that the modem is in an embedded controller with no LAN connectivity (it's all 3G).
I have tried with other servers and authentication modes with the same result.
Basically the connection seems ok, as the dhcp address is issued and attached - as shown.

I'm guessing that there is some simple step or oversight that is leaving me cold.
I can't find any worked examples of using tnis SSL email configuration on an embedded module.
Thanks for the interest.
Don't ask a question if you aren't willing to listen to the answer.
 

Offline hendorog

  • Super Contributor
  • ***
  • Posts: 1617
  • Country: nz
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #18 on: August 19, 2016, 02:36:31 am »
Did you try the DNS and Ping tests?

That would confirm that firstly the modem can lookup the host name and get the IP, and secondly that it can route traffic to it.

Given that there are two 'states' you are seeing I'd try that test in both if you can.
 
The following users thanked this post: SL4P

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #19 on: August 28, 2016, 09:44:29 am »
I've put this one the back burner for now, it was an extra for my own use vs delivering the oroduct...
Thanks for the ideas.
The ping test didn't do what I expected, so I need to see what else is going wrong in the data setup.

cheers
Don't ask a question if you aren't willing to listen to the answer.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3785
  • Country: de
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #20 on: August 28, 2016, 10:53:29 am »
Uh, I second the idea of trying with another SMTP server using the standard port 25. If you want to use GMail, your device must support SSL/TLS, not just simple authentication otherwise Google won't let you connect.

I wouldn't be surprised if your modem didn't support the crypto (or you had to do something extra to enable it), as it is not very common on SMTP.
 

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #21 on: August 28, 2016, 10:58:50 am »
Thanks guys...
I'm pretty sure the problem is at a lower level of connectivity...
I've tried with and without SSL/TLS on a variety of servers, always the same error responses.
With dotted IP, and FQDN - neither works.
As earlier, I get an assigned address, but don't seem to open the IP data path (even though the modem seems to enter data mode)...
Don't ask a question if you aren't willing to listen to the answer.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8270
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #22 on: August 28, 2016, 02:37:18 pm »
The challenge is that the modem is in an embedded controller with no LAN connectivity (it's all 3G).
I have tried with other servers and authentication modes with the same result.
Basically the connection seems ok, as the dhcp address is issued and attached - as shown.

I'm guessing that there is some simple step or oversight that is leaving me cold.
I can't find any worked examples of using tnis SSL email configuration on an embedded module.
Thanks for the interest.
It doesn't need to be on a LAN. You can just set up a very simple server (like the netcat I suggested) on your machine, listening on any port as it seems to be configurable. Then configure on the modem your IP:port as the SMTP server and test to see if it makes a connection and sends something. You can ideally send data from anywhere to anywhere else, that's the idea of the Internet :)
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3785
  • Country: de
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #23 on: August 28, 2016, 02:50:20 pm »
Another tool to debug that would be Wireshark (https://www.wireshark.org). However, you would have to make it connect to as server you control and can sniff the connection to.

Did you configure APN? Not only told the modem to use the "internet" APN - is it actually set up on that modem? If it isn't (or is misconfigured, unable to reach network, etc.) then it would fail to establish IP connection.
 

Offline SL4PTopic starter

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: Send EMAIL using SIM-5320 (3G) HELP please!
« Reply #24 on: August 28, 2016, 10:40:39 pm »
...It doesn't need to be on a LAN.
I don't get this suggestion...  No problem to implement a local server, but It's a 3G modem, how's it goingt to reach a local server when it can't reach any other server?

Same for Wireshark sniffing on a 3G connection (although my experience is very limited - several years ago...)
What are you suggesting?

Excuse my lack of comprehension here!
Don't ask a question if you aren't willing to listen to the answer.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf