Watch this video if you want to see the live demo,
Before you begin make sure your SIM900 GSM module has acquired the network and it is ringing when you make a call to it. Then test the basic AT commands and then proceed further.
Once you are ready, you can start by first setting up the GPRS connection as follows,
Text in RED is typed by me and text in GREEN is the response from SIM900 module.
Setting up GPRS connection
Set the connection type to GPRS
AT+SAPBR=3,1,”Contype”,”GPRS”
OK
Set the APN to to “www” since i am using a Vodafone SIM card, It might be different for you, and depends on the network
AT+SAPBR=3,1,”APN”,”www”
OK
Enable the GPRS
AT+SAPBR =1,1
OK
Query if the connection is setup properly, if we get back a IP address then we can proceed
AT+SAPBR=2,1
+SAPBR: 1,1,”100.120.204.132″
OK
Sending a email to using SMTP protocol
Here in this demonstration i will be using email account NON SSL settings and credentials i got from my web server cPanel as shown below,
Before we begin we need to have the following information for sending email using SIM900 module.
- Receivers email address – (ravi@valetron.com, ravi@marsinnovations.in, ravi@raviyp.in)
- Senders email address – (test@marsinnovations.in)
- Senders email password – (pass123)
- Outgoing SMTP server address – (mail.marsinnovations.in)
- Outgoing SMTP server address port number – (25)
Start by setting up the Email bearer profile identifier
AT+EMAILCID=1
OK
Set the timeout value within which you will enter the email data to be sent, Here i have set it to 30 seconds
AT+EMAILTO=30
OK
Set the SMTP server address and port number
AT+SMTPSRV=”mail.marsinnovations.in”,25
OK
Set the email authentication information
AT+SMTPAUTH=1,”test@marsinnovations.in”,”pass123″
OK
Set the senders email address and Name
AT+SMTPFROM=”test@marsinnovations.in”,”Test”
OK
Set the To email address and Name
AT+SMTPRCPT=0,0,”ravi@valetron.com”,”Ravi”
OK
Set the Cc email address and Name
AT+SMTPRCPT=1,0,”ravi@marsinnovations.in”,”Ravi”
OK
Set the Bcc email address and Name
AT+SMTPRCPT=2,0,”ravi@raviyp.in”,”Ravi”
OK
Set the email Subject, You can set whatever you want. I have set it as MySubject
AT+SMTPSUB=”MySubject”
OK
Time to enter the email content. Enter the below command and you will get a > prompt after which you should type content and press Ctrl+Z when you are done or send 0x1A hex character.
AT+SMTPBODY
> Hello Ravi How are you..fgbmklbgk….
OK
Send the email by entering the below command, if you get the URC +SMTPSEND: 1 then email is successfully sent
AT+SMTPSEND
OK
+SMTPSEND: 1
Now check your receiver email Inbox and you should find the email with text “Hello Ravi How are you..fgbmklbgk….”
Hope it helps someone.
Also see:
2 comments
Hasib
hello sir , i got always 61 error .. how to do it with Gmail?
Ravi PujarAuthor
I dont think it would work with Gmail as it uses IMAP