• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Mock email system 1.0 (Send email to players email. REAL EMAILS!!)

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
  • Author: Mock the bear
  • Tested on: TFS 0.3.6
  • Requeriment:

You can nowsend email to your players! Not like another server you say !email and read all emails <_<
In this scritp you send REAL emails!! An your players go to them hotmails, gemails, wathevermails and read
wink.gif


Well first i will say, i used socket.smpt and used the Yahoo SMTP server. Its free anyone can use it, you only will need a account on Yahoo mail. If you want use another SMTP serverm or your self SMTP server go ahead.
Dont try change the yahoo SMTP ip to gmail SMTP because GMAIL use SSL (Secure socket layer).

First create a account.
Newxt downlaod lua modules
Now add it on talkactions.xml:
Code:
<talkaction log="yes" words="/email" access="5" event="script" value="email.lua"/>
And the email.lua
Lua:
--[[Config]]
local config={
	--Email/pass
	user = '[email protected]',
	pass = 'suasenha123',
	---SMTP config
	smtpserver="smtp.mail.yahoo.com.br", -- dont change it
	smtpport= 587, -- dont change it
}
--Script By mock the bear
local mime = require("mime")
local smtp = require("socket.smtp")
dofile('config.lua')
config.username = serverName
function send_mail(cid,mesgt,config,to)
	local _, err = smtp.send {
	   from = '<'..config.user..'>',
	   rcpt = '<'..to..'>',
	   source = mesgt,
	   user = config.user,
	   password = config.pass,
	   server = config.smtpserver,
	   port = config.smtpport,
	   domain = 'yahoo.com.br',
	}
	if not err then
		addEvent(doPlayerSendTextMessage,100,cid,25,'Email sent')
	else
		addEvent(doPlayerSendTextMessage,100,cid,25,'Cannot send email: '..tostring(err))
	end
end
function getPlayerEmailByName(e) -- Function by mock the bear
	local cid = getPlayerByName(e)
	if not cid or not isPlayer(cid) then
		return false
	end
	local f = db.getResult('select `email` from accounts where id = '..getPlayerAccountId(cid))
	if f:getID() ~= -1 then
		return f:getDataString('email'),f:free()
	else
		return false
	end
end

function onSay(cid, words, param, channel)--Script By mock the bear
	if not smtp then
		doPlayerSendTextMessage(cid,25,'Install lua socket.')
		return true
	end
	local email,sub,msg = param:match('(.-@?.?)%s*,%s*(.-)%s*,%s*(.+)')
	if not email:find('@') then
		email = getPlayerEmailByName(email)
	end
	if sub and msg then
		if not email or email:len() < 3 then
			doPlayerSendTextMessage(cid,25,'Invalid email.')
			return true
		end
		doPlayerSendTextMessage(cid,25,('Sending email to %s\nSubject:%s\nBody:%s'):format(email,sub,msg))
		local mesgt =  smtp.message({
		  headers = {
			from = config.username.." "..'<'..config.user..'>',
			to = '<'..email..'>',
			subject = sub,
		  },
		  body = mime.eol(0, ([[%s

%s
Sent by: %s
-----------------------------------
Script by mock the bear
-----------------------------------]]):format(msg or '',serverName or '-',getCreatureName(cid))),
		})
		addEvent(send_mail,200,cid,mesgt,config,email)
	else
		doPlayerSendTextMessage(cid,25,'Use like this: /email [email][email protected][/email], Subject, Message')
	end
	return true
end

Dont forget to config!

You can use the command like this:

In some emails the email sent can be on spam box.
20:55 Sending email to [email protected]
Subject:Hello
Body:Oieeee
20:55 Email sent

More free smpt servers:

http://www.e-eeasy.com/SMTPServerList.aspx
 
Last edited:
Dud Im # 1 Fan You Rock :D! Love Your Scripts And The Movie D:!
 
oo can you pm me the fly system 2.0?
i mean the script or the link :p!
 
@cesar10
you cant because hotmai dont have free SMTP server
 
Code:
[2:46:09.606] [Error - TalkAction Interface]
[2:46:09.606] data/talkactions/scripts/email.lua
[2:46:09.606] Description:
[2:46:09.606] data/talkactions/scripts/email.lua:11: module 'mime' not found:
[2:46:09.606]   no field package.preload['mime']
[2:46:09.606]   no file './mime.lua'
[2:46:09.606]   no file '/usr/local/share/lua/5.1/mime.lua'
[2:46:09.606]   no file '/usr/local/share/lua/5.1/mime/init.lua'
[2:46:09.606]   no file '/usr/local/lib/lua/5.1/mime.lua'
[2:46:09.606]   no file '/usr/local/lib/lua/5.1/mime/init.lua'
[2:46:09.606]   no file '/usr/share/lua/5.1/mime.lua'
[2:46:09.606]   no file '/usr/share/lua/5.1/mime/init.lua'
[2:46:09.606]   no file './mime.so'
[2:46:09.606]   no file '/usr/local/lib/lua/5.1/mime.so'
[2:46:09.606]   no file '/usr/lib/lua/5.1/mime.so'
[2:46:09.606]   no file '/usr/local/lib/lua/5.1/loadall.so'
[2:46:09.606] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/email.lua)

I use linux ubuntu.
 
Last edited:
Code:
[2:46:09.606] [Error - TalkAction Interface]
[2:46:09.606] data/talkactions/scripts/email.lua
[2:46:09.606] Description:
[2:46:09.606] data/talkactions/scripts/email.lua:11: module 'mime' not found:
[2:46:09.606]   no field package.preload['mime']
[2:46:09.606]   no file './mime.lua'
[2:46:09.606]   no file '/usr/local/share/lua/5.1/mime.lua'
[2:46:09.606]   no file '/usr/local/share/lua/5.1/mime/init.lua'
[2:46:09.606]   no file '/usr/local/lib/lua/5.1/mime.lua'
[2:46:09.606]   no file '/usr/local/lib/lua/5.1/mime/init.lua'
[2:46:09.606]   no file '/usr/share/lua/5.1/mime.lua'
[2:46:09.606]   no file '/usr/share/lua/5.1/mime/init.lua'
[2:46:09.606]   no file './mime.so'
[2:46:09.606]   no file '/usr/local/lib/lua/5.1/mime.so'
[2:46:09.606]   no file '/usr/lib/lua/5.1/mime.so'
[2:46:09.606]   no file '/usr/local/lib/lua/5.1/loadall.so'
[2:46:09.606] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/email.lua)

I use linux ubuntu.
install lua socket.
 
PHP:
function getPlayerEmailByName(e) -- Function by mock the bear
	if not cid or not isPlayer(cid) then
		return false
	end
	local f = db.getResult('select `email` from accounts where id = '..getPlayerAccountId(cid))
	if f:getID() ~= -1 then
		return f:getDataString('email'),f:free()
	else
		return false
	end
end
maybe load e-mail of offline players?
PHP:
function getPlayerEmailByName(e) -- Function by mock the bear, edited by P~
	local f = db.getResult('SELECT `accounts`.`email` FROM `accounts`, `players` WHERE `players`.`name` = ' .. db.escapeString(e) .. ' AND `accounts`.`id` = `players`.`account_id`')
	if f:getID() ~= -1 then
		return f:getDataString('email'),f:free()
	else
		return false
	end
end
mysql said:
1 record, executed in 0.0003 second(s)
(it's time of first load of query on dedic with running 2 OTSes)
 
Last edited:
Back
Top