Corona SDK - 电子邮件不发送

时间:2015-01-07 08:35:41

标签: android email lua corona

我正在尝试使用native.showPopup发送电子邮件,但电子邮件永远不会发送,以下是代码:

function scene:createScene( event )
  function sendMail()
    local options =
    {
        to = "yourname@youremail.com",
        subject = "Game Result",
        isBodyHtml = true,
        body = "<html><body>Play Time: <b>10</b> <br> Score: <b>1</b></body></html>"    
    }
    native.showPopup("mail", options)
  end

  -- add some button to send mail
  submitBtn = widget.newButton{
      defaultFile="assets/submit.png",
      over="assets/submit.png",
      width=display.contentWidth/2, height=display.contentHeight/6,
      onPress = sendMail
  }
end
scene:addEventListener( "createScene", scene )
return scene

这是build.settings:

settings = {
    android =
      {
         versionCode = "11",
         usesPermissions =
        {
          "android.permission.INTERNET",
          "android.permission.WRITE_EXTERNAL_STORAGE",
          "android.permission.ACCESS_FINE_LOCATION",
          "android.permission.ACCESS_COARSE_LOCATION",
        }
     },
}

我在模拟器和手机上试过,但没有任何效果。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:-1)

我不知道为什么,但我只是添加一些验证,现在它的工作.. 这里是我做的修订代码:

function sendMail()
    local options =
    {
        to = "yourname@youremail.com",
        subject = "Game Result",
        isBodyHtml = true,
        body = "<html><body>Play Time: <b>10</b> <br> Score: <b>1</b></body></html>"    
    }

    -- add some validation
    -- and this is revision code
    local mailSend = native.showPopup("mail", options)
    if not mailSend then
        native.showAlert( "Alert!", "Mail cannot be send.", { "OK" })
    end
end

THX