Send an authenticating email containing a code without a server.

I am developing an app where I need to verify that the entered email in a textfield belongs to the person who typed it in. When the user hits the verify button, I want to send an email to the entered email containing a generated code(e.g. CJ8z9). After this, the screen should change to a new textfield where the user is allowed to enter a code(they get the code from their email account outside the app, if the account belonged to them).

From my understanding from the documentation of Message UI framework, it is only capable of sending an email if the mail app is setup and the user will always be able to view the contents of the email (and hence the code). Also, they must press send manually? Am I correct in my understanding of Message UI?

If so, it defeats the purpose of authenticating the email for my app. Can the above scenario be done in swiftUI without using a server? Is there any clever way to get around it?

From my understanding from the documentation of Message UI framework, it is only capable of sending an email if the mail app is setup and the user will always be able to view the contents of the email (and hence the code). Also, they must press send manually? Am I correct in my understanding of Message UI?

Yes, that's it. The very goal is to make sure nothing suspicious or hidden may be sent.

Is there any clever way to get around it?

Yes you can… but with a server. So no real way to turn around.
You should not send the mail from the app, but from your server:
  • From the app, post a php to a web site with the email address

  • The website will use the content of the request to get the mail

  • It generates the code and sends the mail

Note that it is not your app that sends the mail. It is the mail app. Your app just pushes the composed message to the mail app, so you have no control over it.

However, another idea (which is not perfect however). But it depends how sure you want to be of the validity address.
  • Embed the code in a QRCode.

  • Send the QRCode in the mail.

  • Ask user to read the QRCode from his/her iPhone (maybe even within the app).

Of course, user could print locally the message and read the QRCode, or read from another iPhone, but that requires this extra step of printing, which many will not do.
Send an authenticating email containing a code without a server.
 
 
Q