Solution to send email from app on iOS and Android

Does anyone have a possible solution or recommendation for being able to send Emails using NSB/Voiltbuilder apps for both iOS and Android.

I have been using cordova-plugin-email-composer successfully for years, but it has stopped working as of iOS 13+. there doesn’t seem to be any solution on the boards, and the plug in hasn’t been updated in years.

Any ideas or recommendations would be much appreciated.
Thank you,
Malcolm

The cordova-plugin-email-composer is no longer maintained, and there is an open issue for the same problem you’re experiencing.

The only other plugin that’s commonly used by our users is cordova-plugin-email.

Using <a href="mailto:some@email.com">Click to send an email</a> should still work for sending email.

Thanks for the information. I will try the cordova-plugin-email and see if it works for iOS.

`Click to send an email’ I used to use this but years ago it stopped working on iOS due to permission issues, so I moved to cordova-plugin-email-composer which worked well for a time.

I’m surprised there isn’t more demand for tools to send/compose email in the cordova world.

Interesting. I’m using

<plugin name="cordova-plugin-email-composer" spec="0.10.1" />

Without any problems 13, 14, 15, 16 (haven’t tried it on 17 yet).

What’s the debugger say?

I haven’t been able to gather any information from the debugger. It seems to just returning nothing from the call, like it’s blocked by iOS security, which I am guessing what is happening.

Hmmm… I don’t recall any specific permissions for that. Are you using the Apple mail app or a 3rd party mail app? JavaScript call or link?

I don’t use the plugin. I use the “php mail function” and post the information to a .php file “sendQPmail.php” on my website using ajax:

//  function in NSB App Studio

function sendEmail() {
  let $from_email, $to_email, EmailText;
    $from_email = txtFromAddress.value;  //  retrieved from form
    $to_email = txtToAddress.value;   //  retrieved from form
    EmailText = "This email sent to you by: \n" + $from_email + "\n\n" + 
          TextareaEmail.value;
    Url = "https://#########.com/qprequests/sendQPmail.php/?toEmail=" + 
          $to_email + "&fromEmail=" + $from_email;  
    var req = Ajax(Url,"POST",EmailText,true); // true..  asynchronous
    setTimeout(function(){NSB.MsgBox("... sending Email!");}, 1000);
}

The php function I call -sendQPmail.php- on my website looks like this:

<?php
header('Access-Control-Allow-Origin: *');
header("Content-type: text/plain; charset=UTF-8");

  $myText = file_get_contents('php://input');
  $toEmail = $_GET['toEmail'];
  $fromEmail = $_GET['fromEmail'];
  $subject = "Quick Planning - itinerary";
  $user_message = stripslashes($myText);
  $message = $user_message;
  $header = "From: do-not-reply@##########.com\n";
  mail($toEmail, $subject, $message, $header);
?>

There is also an example here:

https://www.w3schools.com/php/func_mail_mail.asp

Hope this helps,
Paul

I am not using any particular mail app, as I don’t have control over what the user is using. The NSB app is built with voltbuilder and is in the Apple store for download. It’s a specialized calculator for certain industries and I have it set that if the user wants to email the results of a calculation, it would bring up the send email screen (whatever email app is defaulted) with the results prefilled in on the description, so all they have to do is enter the email address and click send to complete.

Hi Paul, I do not think that would work in my case is the app is not hosted on a server, but actually on the Apple store and downloaded to the users iOS device. I don’t have any server setup that I could call for such a function. It’s an interesting solution though. Thanks

Understood. And you’re saying that when you call


cordova.plugins.email.open({
isHtml: true,
body: output
});

Nothing happens?

Unfortunately nothing happens. However I think there may be a conflict between plugins as I did a simple test with just the email plug in and it worked. I am going to have to do some more tests and trials on this and see if that may be the cause. Argh… cordova plugins will be the death of me…