Listening port of SMTP server.
Data Type: Long
Remarks
25 port is the default SMTP server port to receive email. However, some ISP block outbound 25 port to prevent user to send email directly to other SMTP server. Therefore, many email providers also provide an alternative port 587 to receive email from such users. 465 port is the common port used to receive email over direct SSL connection. If your server uses 465 port, you must set ConnectType to ConnectSSLAuto.
Example
[Visual Basic 6.0, C++, JScript, Delphi] The following example demonstrates how to send email with EASendMail SMTP Component, but it doesn't demonstrates the events usage. To get the full samples of EASendMail, please refer to Samples section.
[VB6, VBA - Send Email with 587 Port] Const ConnectNormal = 0 Const ConnectSSLAuto = 1 Const ConnectSTARTTLS = 2 Const ConnectDirectSSL = 3 Const ConnectTryTLS = 4 Private Sub SendEmail() Dim oSmtp As EASendMailObjLib.Mail Set oSmtp = New EASendMailObjLib.Mail oSmtp.LicenseCode = "TryIt" ' Your SMTP server address oSmtp.ServerAddr = "smtp.emailarchitect.net" ' Set server port oSmtp.ServerPort = 587 ' User and password for ESMTP authentication oSmtp.UserName = "test@emailarchitect.net" oSmtp.Password = "testpassword" ' Most mordern email servers require SSL/TLS connection now ' ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp.ConnectType = ConnectTryTLS ' If your server uses 25 port ' oSmtp.ServerPort = 25 ' If your server uses 465 port with SSL/TLS ' oSmtp.ConnectType = ConnectSSLAuto ' oSmtp.ServerPort = 465 ' If your server uses 25/587 port with SSL/TLS ' oSmtp.ConnectType = ConnectSSLAuto ' oSmtp.ServerPort = 587 oSmtp.FromAddr = "test@emailarchitect.net" oSmtp.AddRecipient "Support Team", "support@adminsystem.com", 0 oSmtp.Subject = "Test email from VB6, VBA" oSmtp.BodyText = "Hello, this is a test...." If oSmtp.SendMail() = 0 Then MsgBox "Message delivered!" Else MsgBox oSmtp.GetLastErrDescription() End If End Sub
[ASP, VBScript - Send Email with 25 Port] Const ConnectNormal = 0 Const ConnectSSLAuto = 1 Const ConnectSTARTTLS = 2 Const ConnectDirectSSL = 3 Const ConnectTryTLS = 4 Dim oSmtp Set oSmtp = Server.CreateObject("EASendMailObj.Mail") oSmtp.LicenseCode = "TryIt" ' Your SMTP server address oSmtp.ServerAddr = "smtp.emailarchitect.net" ' Set server port oSmtp.ServerPort = 25 ' User and password for ESMTP authentication oSmtp.UserName = "test@emailarchitect.net" oSmtp.Password = "testpassword" ' Most mordern email servers require SSL/TLS connection now ' ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp.ConnectType = ConnectTryTLS ' If your server uses 587 port ' oSmtp.ServerPort = 587 ' If your server uses 465 port with SSL/TLS ' oSmtp.ConnectType = ConnectSSLAuto ' oSmtp.ServerPort = 465 ' If your server uses 25/587 port with SSL/TLS ' oSmtp.ConnectType = ConnectSSLAuto ' oSmtp.ServerPort = 587 oSmtp.FromAddr = "test@emailarchitect.net" oSmtp.AddRecipient "Support Team", "support@adminsystem.com", 0 oSmtp.Subject = "Test email sent from ASP, VBScript" oSmtp.BodyText = "Hello, this is a test...." If oSmtp.SendMail() = 0 Then Response.Write "Message delivered!" Else Response.Write oSmtp.GetLastErrDescription() End If
[JScript/WSH - Send Email using SMTP server with 25 port] var ConnectNormal = 0; var ConnectSSLAuto = 1; var ConnectSTARTTLS = 2; var ConnectDirectSSL = 3; var ConnectTryTLS = 4; function SendEmail() { var oSmtp = new ActiveXObject("EASendMailObj.Mail"); oSmtp.LicenseCode = "TryIt"; // Your SMTP server address oSmtp.ServerAddr = "smtp.emailarchitect.net"; ' Set server port oSmtp.ServerPort = 25 // User and password for ESMTP authentication oSmtp.UserName = "test@emailarchitect.net"; oSmtp.Password = "test"; // Most mordern email servers require SSL/TLS connection now // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp.ConnectType = ConnectTryTLS; // If your server uses 465 port with SSL/TLS // oSmtp.ConnectType = ConnectSSLAuto; // oSmtp.ServerPort = 465; // If your server uses 25/587 port with SSL/TLS // oSmtp.ConnectType = ConnectSSLAuto; // oSmtp.ServerPort = 587; oSmtp.FromAddr = "test@emailarchitect.net"; oSmtp.AddRecipient("Support Team", "support@adminsystem.com", 0); oSmtp.Subject = "Test email sent from ASP, JScript"; oSmtp.BodyText = "Hello, this is a test ...."; if(oSmtp.SendMail() == 0) WScript.Echo("Message delivered!"); else WScript.Echo(oSmtp.GetLastErrDescription()); }
[Visual C++ - Send Email with 25 Port] #include "stdafx.h" #include <tchar.h> #include <Windows.h> #include "EASendMailObj.tlh" using namespace EASendMailObjLib; const int ConnectNormal = 0; const int ConnectSSLAuto = 1; const int ConnectSTARTTLS = 2; const int ConnectDirectSSL = 3; const int ConnectTryTLS = 4; void SendEmail() { ::CoInitialize(NULL); IMailPtr oSmtp = NULL; oSmtp.CreateInstance(__uuidof(EASendMailObjLib::Mail)); oSmtp->LicenseCode = _T("TryIt"); // Your SMTP server address oSmtp->ServerAddr = _T("smtp.emailarchitect.net"); // User and password for ESMTP authentication oSmtp->UserName = _T("test@emailarchitect.net"); oSmtp->Password = _T("test"); // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp->ConnectType = ConnectTryTLS; // If your server uses 587 port // oSmtp->ServerPort = 587; // If your server uses 465 port with SSL/TLS // oSmtp->ConnectType = ConnectSSLAuto; // oSmtp->ServerPort = 465; // If your server uses 25/587 port with SSL/TLS // oSmtp->ConnectType = ConnectSSLAuto; // oSmtp->ServerPort = 587; oSmtp->FromAddr = _T("test@emailarchitect.net"); oSmtp->AddRecipient(_T("Support Team"), _T("support@adminsystem.com"), 0); oSmtp->Subject = _T("Test email from C++"); oSmtp->BodyText = _T("Hello, this is a test email from VC++ ...."); if (oSmtp->SendMail() == 0) _tprintf(_T("Message delivered!")); else _tprintf((const TCHAR*)oSmtp->GetLastErrDescription()); }
[Delphi - Send Email with 25 Port] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, EASendMailObjLib_TLB; // add EASendMail unit type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; const ConnectNormal = 0; ConnectSSLAuto = 1; ConnectSTARTTLS = 2; ConnectDirectSSL = 3; ConnectTryTLS = 4; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var oSmtp : TMail; begin oSmtp := TMail.Create(Application); oSmtp.LicenseCode := 'TryIt'; // Your SMTP server address oSmtp.ServerAddr := 'smtp.emailarchitect.net'; // User and password for ESMTP authentication, oSmtp.UserName := 'test@emailarchitect.net'; oSmtp.Password := 'testpassword'; // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp.ConnectType := ConnectTryTLS; // If your server uses 587 port // oSmtp.ServerPort := 587; // If your server uses 465 port with SSL/TLS // oSmtp.ConnectType := ConnectSSLAuto; // oSmtp.ServerPort := 465; // If your server uses 25/587 port with SSL/TLS // oSmtp.ConnectType := ConnectSSLAuto; // oSmtp.ServerPort := 587; // Set your sender email address oSmtp.FromAddr := 'test@emailarchitect.net'; // Add recipient email address oSmtp.AddRecipientEx('support@emailarchitect.net', 0); // Set email subject oSmtp.Subject := 'simple email from Delphi project'; // Set email body oSmtp.BodyText := 'this is a test email sent from Delphi project, do not reply'; ShowMessage('start to send email ...'); if oSmtp.SendMail() = 0 then ShowMessage('email was sent successfully!') else ShowMessage('failed to send email with the following error: ' + oSmtp.GetLastErrDescription()); end; end.
See Also
ServerAddr Property
User Authentication and SSL Connection
From, ReplyTo, Sender and Return-Path
Process Bounced Email (Non-Delivery Report) and Email Tracking
Online Tutorial
Send Email over SSL/TLS in VB6
Send Email using Gmail in VB6
Send Email using Yahoo in VB6
Send Email using Hotmail/Live in VB6
Send Email over SSL/TLS in Delphi
Send Email using Gmail in Delphi
Send Email using Yahoo in Delphi
Send Email using Hotmail/Live in Delphi
Send Email over SSL/TLS in Visual C++
Send Email using Gmail in Visual C++
Send Email using Yahoo in Visual C++
Send Email using Hotmail/Live in Visual C++