1

我认为 Gmail 正在重写发件人地址并使用网络凭据中提供的帐户作为发件人。

    MailMessage message = new MailMessage();
    message.From = new MailAddress("jimmy@gmail.com");
    message.To.Add(new MailAddress("myacct@gmail.com"));
    message.Subject = "[Yep] Contact Form";
    message.Body = msg;
    message.IsBodyHtml = false;

    SmtpClient client = new SmtpClient();
    client.UseDefaultCredentials = false;
    NetworkCredential networkCredentials = new NetworkCredential("myacct@gmail.com", "pass");
    client.Credentials = networkCredentials;
    client.EnableSsl = true;
    client.Host = "smtp.gmail.com";
    client.Port = 587;

    try
    {
        client.Send(message);

这是收到的电子邮件:

发件人:myacct@gmail.com 收件人:myacct@gmail.com 日期:2012 年 9 月 23 日星期日 14:44:54 -0700 (PDT) 主题:[是] 联系表格内容类型:文本/纯文本;charset=us-ascii 内容传输编码:quoted-printable

这是一个测验

我知道它曾经可以工作,但现在来自始终是我的。如果其他人都遇到这个问题或者只有我一个人,我可以得到确认吗?

4

3 回答 3

2

GMail(和许多其他电子邮件提供商)不允许您更改 FROM 标头。这将允许电子邮件欺骗。

于 2012-09-23T21:52:45.973 回答
1

Dim attachmentFile As String = Nothing If FileUpload1.HasFile Then

        Try
            FileUpload1.SaveAs("C:\files\" + FileUpload1.FileName)
            attachmentFile = FileUpload1.PostedFile.FileName
        Catch ex As Exception
            litStatus.Text = "File Upload Failed !! " + ex.Message.ToString()
        End Try


        Try
            Dim mail As New MailMessage()
            Dim SmtpServer As New SmtpClient("smtp.gmail.com")

            mail.From = New MailAddress("your-gamila-ddress@gmail.com")




            'you have to provide your gmail address as from address'
            mail.[To].Add(txtTo.Text)
            mail.Subject = txtSubject.Text
            mail.Body = txtBody.Text

            Dim attachment As System.Net.Mail.Attachment
            attachment = New System.Net.Mail.Attachment(attachmentFile)
            mail.Attachments.Add(attachment)

            SmtpServer.Port = 587
            SmtpServer.Credentials = New System.Net.NetworkCredential("gamil-username", "gmail-passowrd")


            'you have to provide you gamil username and password'
            SmtpServer.EnableSsl = True
            SmtpServer.Send(mail)
            litStatus.Text = "Email successfully sent."
        Catch ex As Exception
            litStatus.Text = "Mail Send Failed ! " + ex.Message.ToString()
        End Try

    Else
        litStatus.Text = "Please select a file for uploading"
    End If
于 2013-01-27T05:22:27.207 回答
1

要实现此结果,您将不得不选择像 godaddy 这样的自定义电子邮件提供商或从 gmail 购买商业订阅。

您还可以参考 使用 Godaddy SMTP 从 Windows Azure 服务发送邮件

于 2012-09-23T22:12:24.397 回答