Hello, I would appreciate any help…
I’m trying to write some code to send email using a http.post request, I use a php file on my website to send the email, but I’m having a problem passing the text message, I only get the first word of my message. E.g. if my message is “Hello World”, I only get “Hello”.
Here is my AGENT code.
`device.on(“notify”, function(args) {
local msg = args[0].tostring()
local level = args[1].tostring()
local TRGT_URL = "http://wefabdesigns.com/php/mailstatus.php?var1="+"\""+ msg +"\""+"var2=\""+level+"\"";
local request = http.post(TRGT_URL, {}, "");
}); `
PHP Code.
<?php $subject = $_GET['var1']; $txt = $_GET['var2']; $to = "myemail@gmail.com"; $headers = "From: webmaster@example.com"; mail($to,$subject,$txt,$headers); ?>
Edit: Wrapped code in < code > </ code > tags.