βurak Posted December 5, 2022 Posted December 5, 2022 I want to send an email from the lua script, it says it was sent successfully, but the email is not received. server: local allowed = {{48, 57}, {65, 90}, {97, 122 }} function generateString (len) if tonumber (len) then math.randomseed(getTickCount()) local str = "" for i = 1, len do local charlist = allowed[math.random( 1, 3 )] str = str .. string.char (math.random(charlist[1], charlist[2] )) end return str end return false end function sendMailTo (mail, sender, headertext, text) callRemote ("http://localhost/mail.php", EMailAccepted, mail, sender, headertext, text) end function EMailAccepted () outputDebugString ("E-Mail was succesfully sended." ) end addCommandHandler("sendmail", function() local resetKey = generateString(12) sendMailTo("[email protected]", "[email protected]", "Password Reset", "Here your password reset code: "..resetKey) end) php: <?php require_once 'C:\Users\Burak2346\vendor\autoload.php'; $input = mta::getInput(); mail($input[0], $input[2], $input[3], "From: ".$input[1]."\n" . "Content-Type: text/html; charset=iso-8859-1\n"); ?>
Moderators IIYAMA Posted December 5, 2022 Moderators Posted December 5, 2022 31 minutes ago, Burak5312 said: server: I believe the error is about: $input = mta::getInput(); + use MultiTheftAuto\Sdk\Mta; mta > Mta use MultiTheftAuto\Sdk\Mta; $input = Mta::getInput(); 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
βurak Posted December 5, 2022 Author Posted December 5, 2022 other errors are gone but now it gives error like this and the mail is still not coming php: <?php require_once 'C:\Users\Burak2346\vendor\autoload.php'; use MultiTheftAuto\Sdk\Mta; $input = Mta::getInput(); mail($input[0], $input[2], $input[3], "From: ".$input[1]."\n" . "Content-Type: text/html; charset=iso-8859-1\n"); ?>
βurak Posted December 12, 2022 Author Posted December 12, 2022 (edited) Problem Solved The problem of not sending email is because gmail does not have "2-step verification" enabled. For php warnings, it is necessary to check the array with isset. <?php include("sdk/mta_sdk.php"); $input = mta::getInput(); if(isset($input[0]) && isset($input[1]) && isset($input[2]) && isset($input[3])) { $resetMail = mail($input[0], $input[2], $input[3], "From: ".$input[1]."\n" . "Content-Type: text/html; charset=iso-8859-1\n"); if($resetMail){ mta::doReturn("Success"); } else{ mta::doReturn("Failed"); } } ?> Edited December 12, 2022 by Burak5312 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now