Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 12th, 2012  |  syntax: Lua  |  size: 1.21 KB  |  hits: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. local socket = require("socket")
  2. local smtp = require("socket.smtp")
  3. local mime = require("mime")
  4. local ltn12 = require("ltn12")
  5.  
  6.  
  7. source = smtp.message{
  8.   headers = {
  9.      from = "Nego do sabugo <negopretosafado@meu.pau.com>",
  10.      to = "Sapequinha <maiara_07_souza@hotmail.com>",
  11.      subject = "abre ou eu te abro!"
  12.   },
  13.   body = {
  14.     preamble = "",
  15.     [1] = {
  16.       body = mime.eol(0, [[Sapequinha
  17.       ]])
  18.     },
  19.     [2] = {
  20.       headers = {
  21.         ["content-type"] = 'image/jpg; name="sexp"',
  22.         ["content-disposition"] = 'attachment; filename="animal.jpg"',
  23.         ["content-description"] = 'a beautiful image',
  24.         ["content-transfer-encoding"] = "BASE64"
  25.       },
  26.                 body = ltn12.source.chain (
  27.                 ltn12.source.file (io.open ("animal.jpg", "rb")),
  28.                 ltn12.filter.chain (
  29.                 mime.encode ("base64"),
  30.                 mime.wrap ()
  31.          )
  32.        )
  33.     }
  34.   }
  35. }
  36.  
  37. r, e = smtp.send{
  38.     from = "<dalvo_rsn@yahoo.com.br>",
  39.     rcpt = {"<dalvo_rsn@hotmail.com>", "<maiara_07_souza@hotmail.com>"},
  40.     source = source,
  41.     user = "dalvo_rsn",
  42.     password = "759593",
  43.         server = "smtp.mail.yahoo.com.br",
  44.         port = 25,
  45.         domain = "yahoo.com.br",
  46. }
  47.  
  48. if not r then
  49.         print(e)
  50. else
  51.         print "foi"
  52. end