Glengamoi · AspHeute (Artikel) · .NET Heute (RSS-Suche) · .NET Blogs · Glengamoi Suche (Installieren via Klick)

Glengamoi

Die Diskussionsforen der deutschen .NET Community
Willkommen bei Glengamoi. Anmeldung | Registrieren | Hilfe
in Suchen

Email versenden: need fully-qualified hostname

Letzter Beitrag 04-12-2007 17:29 von Chris Cluss. 2 Antworten.
Seite 1 von 1 (3 Treffer)
Beiträge sortieren: Zurück Weiter
  • 01-31-2007 17:25

    Email versenden: need fully-qualified hostname

    Hallo,

    Ich versende Emails mittels Net.Mail.SmtpClient.
        Dim myClient As New Net.Mail.SmtpClient()
        myClient.Host = Mailserver
        myClient.Send(mymsg)

    Der Mailserver des Users (=>Emailadresse) wird vorher per nslookup ermittelt und die Email direkt dort ausgeliefert.

    zu 99% klappt das auch nur bei manchen Mailservern gibt es einen Fehler:
    Exception Details: System.Net.Mail.SmtpException: Command parameter not implemented. The server response was: <H865485>: Helo command rejected: need fully-qualified hostname

    Grund dafür ist offensichtlich, dass er den MachineName beim Übermitteln anstelle eines Domainnames als Hostname im SMTP-Protokoll  einbaut.

    Weiß jemand ob man das irgendwo ändern kann?

    Ich habe schon versucht den Domainname als Machinename zu setzen … aber Punkte dürfen nicht verwendet werden.

    Gruß, Chris

     

     

    • IP-Adresse ist Registriert
  • 01-31-2007 17:49 Antwort zu

    AW: Email versenden: need fully-qualified hostname

    So gehts:

    http://www.eudora.com/techsupport/kb/2580hq.html

    19.2.2007: Leider gehts so doch nicht :-(

     

     

    • IP-Adresse ist Registriert
  • 04-12-2007 17:29 Antwort zu

    AW: Email versenden: need fully-qualified hostname

    Aber so gehts!!

     

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim msg As New Net.Mail.MailMessage("you@yourDomain.com, me@myDomain.com, "Hello ", "World")

        Dim s As New Trinet.Net.Mail.SmtpClientEx

        s.Host = "mail.yourdomain.com"

        s.Send(msg)

     

    Exit Sub

     

    -----------------------------------------------------------

    Imports Microsoft.VisualBasic

    Imports System

    Imports System.Net.Mail

    Imports System.Net.NetworkInformation

    Imports System.Reflection

     

    Namespace Trinet.Net.Mail

    ''' <summary>

    ''' An extended <see cref="SmtpClient"/> which sends the

    ''' FQDN of the local machine in the EHLO/HELO command.

    ''' </summary>

    Public Class SmtpClientEx

    Inherits SmtpClient

    Private Shared localHostName As FieldInfo = GetLocalHostNameField()

    ''' <summary>

    ''' Initializes a new instance of the <see cref="SmtpClientEx"/> class

    ''' that sends e-mail by using the specified SMTP server and port.

    ''' </summary>

    ''' <param name="host">

    ''' A <see cref="String"/> that contains the name or

    ''' IP address of the host used for SMTP transactions.

    ''' </param>

    ''' <param name="port">

    ''' An <see cref="Int32"/> greater than zero that

    ''' contains the port to be used on host.

    ''' </param>

    ''' <exception cref="ArgumentNullException">

    ''' <paramref name="port"/> cannot be less than zero.

    ''' </exception>

    Public Sub New(ByVal host As String, ByVal port As Integer)

    MyBase.New(host, port)

    Initialize()

    End Sub

    ''' <summary>

    ''' Initializes a new instance of the <see cref="SmtpClientEx"/> class

    ''' that sends e-mail by using the specified SMTP server.

    ''' </summary>

    ''' <param name="host">

    ''' A <see cref="String"/> that contains the name or

    ''' IP address of the host used for SMTP transactions.

    ''' </param>

    Public Sub New(ByVal host As String)

    MyBase.New(host)

    Initialize()

    End Sub

    ''' <summary>

    ''' Initializes a new instance of the <see cref="SmtpClientEx"/> class

    ''' by using configuration file settings.

    ''' </summary>

    Public Sub New()

    MyBase.New()

    Initialize()

    End Sub

    ''' <summary>

    ''' Gets or sets the local host name used in SMTP transactions.

    ''' </summary>

    ''' <value>

    ''' The local host name used in SMTP transactions.

    ''' This should be the FQDN of the local machine.

    ''' </value>

    ''' <exception cref="ArgumentNullException">

    ''' The property is set to a value which is

    ''' <see langword="null"/> or <see cref="String.Empty"/>.

    ''' </exception>

    Public Property Local_HostName() As String

    Get

    If (Nothing Is localHostName) Then

    Return Nothing

    End If

    Return CType(LocalHostName.GetValue(Me), String)

    End Get

    Set(ByVal value As String)

    If String.IsNullOrEmpty(value) Then

    Throw New ArgumentNullException("value")

    End If

    If (Not (localHostName) Is Nothing) Then

    localHostName.SetValue(Me, value)

    End If

    End Set

    End Property

    ''' <summary>

    ''' Returns the price "localHostName" field.

    ''' </summary>

    ''' <returns>

    ''' The <see cref="FieldInfo"/> for the private

    ''' "localHostName" field.

    ''' </returns>

    Private Shared Function GetLocalHostNameField() As FieldInfo

    Dim flags As BindingFlags = (BindingFlags.Instance Or BindingFlags.NonPublic)

    Return GetType(SmtpClient).GetField("localHostName", flags)

    End Function

    ''' <summary>

    ''' Initializes the local host name to

    ''' the FQDN of the local machine.

    ''' </summary>

    Private Sub Initialize()

    Dim ip As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties

    If (Not String.IsNullOrEmpty(ip.HostName) _

    AndAlso Not String.IsNullOrEmpty(ip.DomainName)) Then

    Me.Local_HostName = (ip.HostName + ("." + ip.DomainName))

    End If

    End Sub

    End Class

    End Namespace

     

    http://forums.microsoft.com/MSDN/showpost.aspx?postid=1465007&siteid=1

    • IP-Adresse ist Registriert
Seite 1 von 1 (3 Treffer)