嘿伙计们,我正在使用一个基本上将所有电子邮件发送给用户的功能。但是,它只会向我们服务器上的用户发送电子邮件。任何使用@gmail 或@hotmail 的人似乎都没有收到我们的电子邮件。这是代码。这同样适用于我的服务器电子邮件,但外部电子邮件不会发送出去。
该网站托管在我们的服务器上。
Public Function SendMail(ByVal EmailFrom As String, ByVal EmailTo As String, ByVal EmailBcc As String, ByVal EmailSubject As String, ByVal EmailBody As String, ByVal Attachment As String) As Boolean
Dim EmailMessage As New Net.Mail.MailMessage
EmailMessage = New Net.Mail.MailMessage(EmailFrom, EmailTo, EmailSubject, EmailBody)
If EmailBcc <> "" Then
EmailMessage.Bcc.Add(EmailBcc)
End If
Dim MailClient As New Net.Mail.SmtpClient("exchange1", 25)
MailClient.UseDefaultCredentials = False
' MailClient.EnableSsl = False
EmailMessage.IsBodyHtml = True
If Attachment <> "" Then
Dim EMailAttachment As New System.Net.Mail.Attachment(Attachment)
EmailMessage.Attachments.Add(EMailAttachment)
End If
Try
MailClient.Send(EmailMessage)
Return True
Catch ex As Exception
'MsgBox("Email Error: " & ex.Message)
' Return False
End Try
End Function
编辑:谁能解释为什么当我部署到我的网络服务器时发送电子邮件,但当我在我的本地主机 iis 中时却没有?