- Author: Mock the bear
- Tested on: TFS 0.3.6
- Requeriment:
- Lua socket > Lua modules > download here
- Account on yahoo mail
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
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"/>
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:
- /email Mock,Assunto,Mensagem
- /email [email protected],Assunto,Mensagem
In some emails the email sent can be on spam box.
More free smpt servers:
http://www.e-eeasy.com/SMTPServerList.aspx
Last edited: