Jump to content

problem in sendEmail


#RooTs

Recommended Posts

hello guys. 
initially, sorry me for my english.

I'm having difficulty using this feature.
https://community.multitheftauto.com/index.php?p=resources&s=details&id=11231

 

I've already done the entire procedure. tested everything
I did the entire procedure. but it didn't work

OBS: I also changed the ACL. i tried everything

( any solution? please help )

server.lua

Spoiler
local randomMails = {"[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]"}
function fromRandom()
    return randomMails[math.random(#randomMails)]
end

function sendCustomMail(subject, header, sendto, mail)
	local header = "From: "..subject.." <"..(header or fromRandom())..">"
	callRemote("http://multitheftauto.rf.gd/sendemail/mailer.php", returns, subject, header, sendto, mail) -- This website is not available any more so add the PHP files in your own website and put URL here.
end
addEvent("sendEMail", true)
addEventHandler("sendEMail", root, sendCustomMail)

function returns(msg, num)
	if msg == "ERROR" or (not msg) then
		outputDebugString("E-Mail not sent due to webpage errors, check the script and/or page provided.", 2)
	else
		outputDebugString(msg, num or 3)
	end
end

 



cliente.lua
 

Spoiler
local screenW, screenH = guiGetScreenSize()
email_wnd = guiCreateWindow((screenW - 366) / 2, (screenH - 408) / 2, 366, 408, "Ingame E-Mail Service", false)
	guiWindowSetSizable(email_wnd, false)
subject_edit = guiCreateEdit(9, 22, 347, 27, "Subject...", false, email_wnd)
header_edit = guiCreateEdit(9, 55, 195, 27, "Send from...", false, email_wnd)
sendto_edit = guiCreateEdit(9, 87, 347, 27, "Send to...", false, email_wnd)
random_check = guiCreateCheckBox(204, 55, 152, 27, "Send from random mail?", false, false, email_wnd)
mail_mem = guiCreateMemo(9, 150, 347, 223, "You can use any HTML codes in this message body...", false, email_wnd)
send_btn = guiCreateButton(9, 375, 174, 23, "Send!", false, email_wnd)
    guiSetProperty(send_btn, "NormalTextColour", "FFAAAAAA")
close_btn = guiCreateButton(182, 375, 174, 23, "Close", false, email_wnd)
    guiSetProperty(close_btn, "NormalTextColour", "FFAAAAAA")

local buttons = {}
buttons.bold = guiCreateButton(10, 122, 49, 27, "Bold", false, email_wnd)
buttons.italic = guiCreateButton(69, 122, 49, 27, "Italic", false, email_wnd)
buttons.size = guiCreateButton(128, 122, 49, 27, "Size", false, email_wnd)
buttons.next = guiCreateButton(187, 122, 49, 27, "Next Line", false, email_wnd)
buttons.url = guiCreateButton(246, 122, 49, 27, "Insert URL", false, email_wnd)
buttons.img = guiCreateButton(305, 122, 49, 27, "Insert Image", false, email_wnd)
guiSetVisible(email_wnd, false)

function toggleGUI()
	if (guiGetVisible(email_wnd)) then
		guiSetVisible(email_wnd, false)
		showCursor(false)
	else
		guiSetVisible(email_wnd, true)
		showCursor(true)
	end
end
addEventHandler("onClientGUIClick", close_btn, toggleGUI, false)
addCommandHandler("email", toggleGUI)

function sendMail()
	local subject = guiGetText(subject_edit)
	if guiCheckBoxGetSelected(random_check) then
		header = false
	else
		header = guiGetText(header_edit)
	end
	local sendto = guiGetText(sendto_edit)
	local mail = guiGetText(mail_mem)
	if (#subject < 5) or (#sendto < 5) or (#mail < 5) then
		outputChatBox("Email not sent: One of the required fields had less than 5 characters!", 200, 0, 0)
		return
	end
	triggerServerEvent("sendEMail", resourceRoot, subject, header, sendto, mail)
end
addEventHandler("onClientGUIClick", send_btn, sendMail, false)

function handleRandom()
	if guiCheckBoxGetSelected(random_check) then
		guiSetEnabled(header_edit, false)
	else
		guiSetEnabled(header_edit, true)
	end
end
addEventHandler("onClientGUIClick", random_check, handleRandom, false)

-- Below are functions for HTML code buttons...
for k, v in pairs(buttons) do
	guiSetProperty(v, "NormalTextColour", "FFAAAAAA")
end

function resetMemo()
	local txt = guiGetText(mail_mem)
	if string.find(txt, "You can use any HTML codes in this message body...") then
		guiSetText(mail_mem, "")
	end
end
addEventHandler("onClientGUIClick", mail_mem, resetMemo, false)

function handleButtons()
	if source == buttons.bold then
		guiSetText(mail_mem, guiGetText(mail_mem).."<b></b>")
	--	guiMemoSetCaretIndex(mail_mem, guiMemoGetCaretIndex(mail_mem) + 3)
	elseif source == buttons.italic then
		guiSetText(mail_mem, guiGetText(mail_mem).."<i></i>")
	--	guiMemoSetCaretIndex(mail_mem, guiMemoGetCaretIndex(mail_mem) + 3)
	elseif source == buttons.size then
		guiSetText(mail_mem, guiGetText(mail_mem).."<font size='3'></font>")
	--	guiMemoSetCaretIndex(mail_mem, guiMemoGetCaretIndex(mail_mem) + 15)
	elseif source == buttons.next then
		guiSetText(mail_mem, guiGetText(mail_mem).."<br>")
	--	guiMemoSetCaretIndex(mail_mem, guiMemoGetCaretIndex(mail_mem) + 4)
	elseif source == buttons.url then
		guiSetText(mail_mem, guiGetText(mail_mem).."<a href='URLHERE'></a>")
	--	guiMemoSetCaretIndex(mail_mem, guiMemoGetCaretIndex(mail_mem) + 18)
	elseif source == buttons.img then
		guiSetText(mail_mem, guiGetText(mail_mem).."<img src='IMAGEURL.png'>")
	--	guiMemoSetCaretIndex(mail_mem, guiMemoGetCaretIndex(mail_mem) + 24)
	else
		return
	end
end
addEventHandler("onClientGUIClick", root, handleButtons)

 


mailer.php
 

Spoiler
<?php
    include( "mta_sdk.php" );
    $input = mta::getInput();
    $subject  = $input[0];
    $email    = $input[2];
    $message  = $input[3];
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= $input[1] . "\r\n";
    $mailSent = mail($email, $subject, $message, $headers);
    if ($mailSent) {
        mta::doReturn("Email sent to ".$email);
        echo "\r\nMail sent to $email with text: $message!";
    }
    else
    {
        mta::doReturn("Failed to send email to ".$email." - Unknown error, restart script and check webpage!", 2);
    }
?>

 


my files in callRemote
http://multitheftauto.rf.gd/sendemail/

Link to comment
  • Tut locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...