SmtpHello Method |
Namespace: MailBee.SmtpMail
Exception | Condition |
---|---|
MailBeeException | An error occurred and ThrowExceptions is true. |
Sends EHLO or HELO command to the server. This command must be issued immediately after the connection was established.
EHLO/HELO command has a parameter which should the domain name of the host which will send mail. By default, MailBee uses either the IPv4 address of the current machine or the local host name if IPv4 address is not available. Usually, this behavior does not need to be changed. However, if the application logic requires the default behavior to be overridden, the developer can force any arbitrary string to be used as a parameter of HELO/EHLO command by setting HelloDomain property of the server which is already in SmtpServers collection, or by using Add(SmtpServer) method to add new server into the collection.
By default, the component sends EHLO command, which is an extended version of HELO command. An ESMTP-enabled server returns the list of server capabilities in reply to EHLO command. However, if the server does not support any ESMTP extensions, it will return an error. In this case, the component will try HELO command. However, the list of the server capabilities will not be available, and GetExtensions will return a null reference (Nothing in Visual Basic).
If the application knows the server it uses does not support ESMTP, it can disable EHLO (so that HELO will be used) by setting SmtpOptions to ClassicSmtpMode.
In case if you connected to port 587, MailBee will by default (if AutodetectPortAndSslMode is true) also try to switch the connection to TLS (if the server supports it). A separate StartTls call is not required.
// To use the code below, import these namespaces at the top of your code. using System; using MailBee; using MailBee.SmtpMail; // The actual code (put it into a method of your class) Smtp mailer = new Smtp(); mailer.SmtpServers.Add("smtp.domain.com"); mailer.Connect(); mailer.Hello(); Console.WriteLine(mailer.GetServerResponse()); mailer.Disconnect();