Sends initial greeting to the SMTP server.
true if the method succeeds; otherwise, false.
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 local host name or the domain part of sender's e-mail address if it's already known to the moment when Hello is called. 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 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.
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
This sample connects to the SMTP server, sends greeting, and prints the response received form the server into console.
[C#] // 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();
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code. Imports MailBee Imports MailBee.SmtpMail ' The actual code (put it into a method of your class) Dim mailer As New Smtp mailer.SmtpServers.Add("smtp.domain.com") mailer.Connect() mailer.Hello() Console.WriteLine(mailer.GetServerResponse()) mailer.Disconnect()
Smtp Class | MailBee.SmtpMail Namespace | GetExtensions