#792 E-mail API

baeltazor Sun 18 Oct 2009

hello, in the code-view of the ide i'm making for fan, i'm building an e-mail wizard where you simply enter the credentials/port/host info into a form and then the wizard will generate and insert the appropriate code to be able to send emails. But i'm having difficulty getting the email to work, i have the following code:

class Sending {

Str testHost   := "smtp.live.com"
Str testUser   := "[email protected]"
Str testPass   := "*************"
Str testTo     := "[email protected]"
Str testFrom   := "[email protected]"
Bool debug     := true

SmtpClient makeClient()
{
  c := SmtpClient
  {
    host     = testHost
    username = testUser
    password = testPass
  }
  if (debug) c.log.level = LogLevel.debug
  return c
}

Void main()
{
  SendMail
}

Void SendMail()
{
  email := Email
  {
    to = [testTo]
    from = testFrom
    subject = "Test E-mail."
    body = TextPart { text = "Hey, How's it hangin'?" }
  }

  makeClient.send(email)
}
  echo("--- To, CC, BCC ---")
  email.encode(Sys.out)
}

}

can somebody please tell me where i'm going wrong here?

KevinKelley Sun 18 Oct 2009

needs a using email statement at the top, and you've got three extra lines

echo("--- To, CC, BCC ---")
email.encode(Sys.out)
}

pasted in there, but other than that it works for me.

baeltazor Sun 18 Oct 2009

oh my, i feel so stupid today, how could i have overlooked such i basic thing lol. thank you KevinKelley, much appreciated.

baeltazor Sun 18 Oct 2009

Ooh! I didn't see that test email in my Pending folder. Thanks! It's still not working for me. So maybe I'll check my firewall? or something, I've never had luck in any language when trying to send email. Weird.

Login or Signup to reply.