如何更改" From"没有未经过身份验证的SMTP服务器的电子邮件地址?

时间:2017-08-07 03:14:40

标签: c# .net visual-studio email smtp

所有

我正在编写一个允许客户直接从他们的桌面提交支持服务单的应用程序。话虽这么说,我喜欢" FROM"电子邮件地址为他们的电子邮件地址。

我目前有以下代码:

public void SendTicketEmail()
    {
        try
        {
            string tEmail = materialListView1.SelectedItems[0].SubItems[1].Text;
            string tPhone = materialListView1.SelectedItems[0].SubItems[2].Text;
            string tUser = materialListView1.SelectedItems[0].Text;

            MailMessage mail = new MailMessage(tEmail, "my email");
            SmtpClient client = new SmtpClient();
            client.Port = 25;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Host = "smtp.simplifymsp.com";
            mail.Subject = "this is a test email.";
            mail.Body = "this is my test email body";
            client.Send(mail);
        }

        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
            return;
        }
    }

我假设此时我的解决方案是请求我的托管服务启用一个选项,我可以允许smtp外发电子邮件而无需在指定端口上进行身份验证?

这里的替代方案是让每个客户的所有支持电子邮件来自我的预设电子邮件地址之一,并在主题中包含客户ID,然后在我的服务台票务系统中为每个分配客户的客户创建工作流程#39;该票证的信息。这比我做的工作更多,特别是在缩放时。

提前谢谢。

1 个答案:

答案 0 :(得分:0)

对于它的价值,我相当简单地解决了这个问题。 FreshService(我用于我的票务系统的网站)对以下代码做出了很好的反应:

mail.From = new MailAddress("me@me.com", "customer@customer.com");

即使电子邮件来自“me@me.com”,FreshService仍会将该票据视为来自客户。工作得很漂亮。

谢谢大家的时间。