Send Email from VisualNEO Web - Forum

Forum Navigation
You need to log in to create posts and topics.

Send Email from VisualNEO Web

I looked on the forum for this, as well as the help file and can no mention of how to send email.   I'm sure I'm missing it, but ..  can someone direct me to information regarding the process of email from our apps?

Thanks

Take a look at the YOUTUBE channel of Visualneo web ("How to Code a Database App - PART 4_ Delete records from the database"...at about 3 minutes.)

https://www.youtube.com/watch?v=gAynliYxLSs

Hope this helps !

Denis

rcohen has reacted to this post.
rcohen
@rcohen ending an email is a server side functionality, unless you just want a simple link to open the local email application. In the last case just right click a Container object and add this HTML code:

<a href="mailto:name@domain.com">Click here to send us an email!</a>
It is possible to send the data submited from a VisualNEO Web form object to an email address using PHP on a web server.
Just copy this code into a plain text editor and save it as "senddata.php" (change first the email addressses), then upload it to your webserver:

<?php 
//Header required when app and php are of different origins 
header("Access-Control-Allow-Origin: *"); 
$message="";
if($_SERVER["REQUEST_METHOD"] === "POST"){
     foreach($_POST as $key => $value){
          $message .= "".htmlspecialchars($key).": ".htmlspecialchars($value)."\r\n";
     }
     $to = "somebody@example.com";
     $subject = "My subject";
     $headers = "From: webmaster@example.com" . "\r\n" . "CC: somebodyelse@example.com";
     mail($to,$subject,$message,$headers);
     echo "EMAIL SUCCESSFULLY SEND";
}else{
     $result = "INVALID DATA";
     echo $result;
}
?>

Then add a Form object with some TextInputs and/or a TextArea objects and a Form Submit object to send the Form. In the Form "action" property type the full URL to your PHP script. For example:

https://yourdomain.com/myscripts/senddata.php

I hope it helps.

Regards.

smartmedia has reacted to this post.
smartmedia

Ahhhh.... [click]   ;-)

I got it.

When directing this to forms that do not belong to us, is the return from said page always land in [DATA]  ?

Thank you

When directing this to forms that do not belong to us, is the return from said page always land in [DATA] ?

Sorry, I don't understand your question. About understanding how to work with Forms please take a look at the included sample app "FormSubmit".

Best regards.

rcohen has reacted to this post.
rcohen

Hi Luis,

About the "submit script" in PHP.

Let's imagine I have a variable ( in VisualNeo Web ) : [email], how can I use the value of this variable in the "submit script"  instead of  "somebody@example.com".

How to pass a VisualNeoWeb [variable] to a Php $to=variable ? If it is possible....

Best regards,

@cdy44-2 yes it's possible, you can send the information in a form InputText field. Just be sure to give it a "property-name" value under the Properties panel. If you use property-name: targetEmail then replace this line in the .php file:

$to = "somebody@example.com";

With this one:

$to = $_POST['targetEmail'];

And done :)

Anyway I have succesfully sent emails without using server side code using SMTP2go.
The API can be called directly form JavaScript and allows up to 1000 emails sent a month for free:

BeginJS
var url = "https://api.smtp2go.com/v3/email/send";
$.ajax({
  url: url,
  method: 'POST',
  headers: {
    'Content-Type': "application/json"
  },
  data: JSON.stringify({
    'api_key': "PUT HERE YOUR API KEY",
    'sender': "Your Name <your.name@yourdomain.com>",
    'to': [
      "Target Name <target.name@hisdomain.com>"
    ],
    'subject': "Your subject",
    'html_body': "Your email content in html format"
  }),
}).done(function(result) {
  console.log(result);
}).fail(function(err) {
  throw err;
});
EndJS

It takes some time to configure the SMTP2GO account, but once it's ready works very good.
All emails from visualneo.com (including those sent from this forum) are sent by SMTP2GO service. When sendind a lot of emails a day it's quite more reliable than the hosting default service.

Regards.

CDY@44, danito and Darbdenral have reacted to this post.
CDY@44danitoDarbdenral

Thank you for the quick answer !

Hola,

Tengo una pregunta básica pero pertenece a este hilo (que me parece muy importante).

He realizado una aplicación que envía un formulario según el sistema propuesto a un PHP y se envía correctamente.

He conseguido modificar desde VisualNeo web las variables $to y $message sin problemas.

No puedo hacerlo con $headers, pero parecen tener un formato distinto. Parecen como 3 cadenas de texto separadas. ¿Se puede?

Por otro lado queria saber si es posible enviar un correo en HTML, como una plantilla o algo asi.

Muchas gracias.

@juancasev en este enlace se explica como enviar un mail con HTML desde PHP. Los $headers están protegidos cotra inyección de código por razones de seguridad:
https://www.w3schools.com/php/func_mail_mail.asp

Po otro lado, la solución que comparto en este mismo hilo para enviar emails utilizando SMTP2GO es muy útil y no requiere un script en el servidor. Merece la pena echarle un vistazo. El único problemas es configurar el dominio desde donde enviar los emails correctamente, pero como digo merece mucho la pena.

Saludos.

smartmedia and Juancasev have reacted to this post.
smartmediaJuancasev

Muchas gracias, @luishp por el código en Javascript para enviar correos usando SMTP2go.

He conectado las variables de VisualNeo con las de Javascript con éxito para enviar los correos personalizados.

Mi pregunta es: ¿cómo podría adjuntar una imagen al correo o insertarla en el body? Concretamente una imagen  previamente capturada con el plugin NeoWebcam en BASE64 JPG?

Muchas gracias de anemano.

Saludos.

________________________________________

Thank you very much @luishp for the Javascript code to send mails using SMTP2go.

I have successfully connected the VisualNeo variables with the Javascript variables in order to send custom emails.

Now, my question is about how I could attach to the mail or insert in the body an image previously captured with the NeoWebcam plugin in BASE64 JPG.

Thank you very much for your support.

Best regards.

 

@tonyspacex No he implementado esa posibilidad dentro del plugin pero si tienes paciencia intentaré añadirla lo antes posible.

I have not implemented that possibility within the plugin but if you have patience, I will try to add it as soon as possible.

Gracias!

CDY@44, Darbdenral and 2 other users have reacted to this post.
CDY@44DarbdenraltonyspacexJuancasev

Gracias por rápida respuesta, @luishp. Mientras tanto, ¿no hay alguna forma de poder añadir archivos adjuntos al email añadiendo una línea JSON.stringify a tu código Javascript para SMTP2go? Muchas gracias.

Thanks for quick response. In the meantime, isn't there a way to add attachments to the emails by adding a JSON.stringify line to your SMTP2go Javascript code? Thank you very much.

@tonyspacex puedes hacerlo utilizando neoAjaxSend. Esta es la estructura del JSON para enviar un archivo adjunto mediante SMTP2GO:

{
    "api_key": "api-40246460336B11E6AA53F23C91285F72",
    "to": ["Test Person <test@example.com>"],
    "sender": "Test Persons Friend <test2@example.com>",
    "subject": "Hello Test Person",
    "text_body": "You're my favorite test person ever",
    "html_body": "<h1>You're my favorite test person ever</h1>",
    "attachments": [
        {
            "filename": "image.jpg",
            "fileblob": "--base64-data--",
            "mimetype": "image/jpeg"
        }
    ]
}

Donde pone "--base64-data--" cambialo por $App.NombreVariable, donde NombreVariable es la variable donde guardas el contenido en formato Base64 del archivo a enviar. También asegurate de utilizar el tipo mime adecuado y el nombre de archivo que quieras.
Más información aquí.

Una vez tengas el JSON correctamente formado y guardado en una varible (en mi ejemplo siguiente [myjson]) envíalo mediante neoAjaxSend:

neoAjaxSend "https://api.smtp2go.com/v3/email/send" "POST" "[myjson]" "json" "" ""

Cualquier duda, me dices.

tonyspacex has reacted to this post.
tonyspacex

Muchas gracias, @luishp. Gracias a tu asistencia he logrado configurar con éxito la función que necesitaba y ahora la app ya puede enviar las capturas tomadas con NeoWebcam por email como archivos adjuntos.

Saludos.

 

 

luishp has reacted to this post.
luishp

Luis,

I put up the server side  php script, built the form, pointed it to the script and when submit is pressed I get an email with no content and no data from the text area inside the form. I have tried everything (except for the correct thing) Any ideas on what might be causing this issue. That loop you have in there is passing on the values of the variables from the form, right?

@pfavaro be sure to add a property-name to each form field (see attached picture) so it can be detected on server side.
If you want me to take a look at your app I will be more than happy to help.

Uploaded files:
  • You need to login to have access to uploads.