Comparison of charges to send one email<\/figcaption><\/figure>\nFollowing code from zeptomail sends the email . For this to work you need to get the user name and password from zeptomail. The body to be modified to have the OTP text included. OTP is generated by the function generateotp.<\/p>\n
\n
\r\nimport smtplib, ssl, random\r\nfrom email.message import EmailMessage\r\nport = 587\r\nsmtp_server = \"\"\r\nusername=\"\"\r\npassword = \"\"\r\nmessage = \"Test email sent successfully.\"\r\nmsg = EmailMessage()\r\nmsg['Subject'] = \"Test Email\"\r\nmsg['From'] = \"\"\r\nmsg['To'] = \"\"\r\nmsg.set_content(message)\r\ntry:\r\n if port == 465:\r\n context = ssl.create_default_context()\r\n with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:\r\n server.login(username, password)\r\n server.send_message(msg)\r\n elif port == 587:\r\n with smtplib.SMTP(smtp_server, port) as server:\r\n server.starttls()\r\n server.login(username, password)\r\n server.send_message(msg)\r\n else:\r\n print (\"use 465 \/ 587 as port value\")\r\n exit()\r\n print (\"successfully sent\")\r\nexcept Exception as e:\r\n print (e)\r\n\r\ndef generateotp(glen = 4):\r\n gchars = '0123456789'\r\n gsl = ''.join(random.choice(gchars) for _ in range(glen))\r\n return gsl\r\n<\/code><\/pre>\n<\/div>\nThe email received in the user inbox is shown below.<\/p>\n
Email OTP received in the user inbox<\/figcaption><\/figure>\nOne needs to enter this in the enter OTP text field. Once the OTP is generated, the MDButton with id otpbuttonis moved and the other MDButton with ID validatebutton will be moved below the second text field that is used to enter the OTP received.<\/p>\n
Display of OTP received and the validate OTP button<\/figcaption><\/figure>\nThe user will also get an option to send the OTP again after 60 seconds and the time to resend the OTP will reduce by using a timer with Schedule_interval method.<\/p>\n
Message to send the OTP again with timer<\/figcaption><\/figure>\nOnce the time of 60 seconds is expired, the user will be provided with an option to send the OTP again as seen in the image below.<\/p>\n
Display of the button to resend the OTP<\/figcaption><\/figure>\nOnce the right OTP is entered, it will be checked against the value entered in the database and if the value matches, the value curemail is updated with the email id entered. The user will be moved to the new screen as shown in the image below.<\/p>\n
Screen showing logged in after successful verification of the OTP<\/figcaption><\/figure>\nThis screen has another button to logout. If the user clicks the logout button, the curemail entry in the database table settings will be set to “”. While the app is started, it the curemail is not empty, the user will be shown the loggedin screen without showing the screen to generate an validate the OTP. This will be convenient for the user if they use the app regularly.<\/p>\n
This is how the email OTP authentication in android works.<\/p>\n
<\/span>Convert the python code to android apk<\/span><\/h2>\nFollowing code is used to convert the python code to an android apk. Please refer the detailed post on