2015-02-07 72 views

回答

1

假設你正在使用C#,是的,這是可能的。

This SO question可能會幫助你。 One of the answers claim to have a working code如下:

我只是用下面的代碼成功發送電子郵件從Unity 3D:

using System.Net; 
using System.Net.Mail; 

using UnityEngine; 

public class SendMail : MonoBehaviour { 
    public string sender = "[email protected]"; 
    public string receiver = "[email protected]"; 
    public string smtpPassword = "mysmtppassword"; 
    public string smtpHost = "mail.mymailacount.com"; 

    // Use this for initialization 
    private void Start() { 
     using (var mail = new MailMessage { 
      From = new MailAddress(sender), 
      Subject = "test subject", 
      Body = "Hello there!" 
     }) { 
      mail.To.Add(receiver); 

      var smtpServer = new SmtpClient(smtpHost) { 
       Port = 25, 
       Credentials = (ICredentialsByHost)new NetworkCredential(sender, smtpPassword) 
      }; 
      ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; 
      smtpServer.Send(mail); 
     } 
    } 
} 
相關問題