Error with sending recipient(Relay denied)


This is most popular issue with send email with specified SMTP server. We'll explain why and also provide solutions in this article.

When EASendMail sends email to SMTP server, SMTP server will detect if the recipient is a local user(mailbox is on the current server), if it is not, SMTP server will relay it to the remote server. But to stop the increasing spam, most SMTP servers disabled relaying email to remote server. That is why "Error with sending recipient" occurs when you are sending email to a remote recipient via your SMTP server.

To enable local user relay email to remote recipient, most SMTP servers provide ESMTP authentication. Once the user authentication succeeded, SMTP server will relay email to any domain without limitation.

How to ESMTP authentication?

You can just simply assign your user name and password to UserName and Password property, then EASendMail will perform ESMTP authentication automatically before the email was sent. The user name and password is usually same as your pop3 user name and password.

Example

[Visual Basic 6.0, C++, JScript] 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.

[Visual Baisc]		
Private Sub SendEmail()
  Dim oSmtp As EASendMailObjLib.Mail
  Set oSmtp = New EASendMailObjLib.Mail
  
  'The license code for EASendMail ActiveX Object,
  'for evaluation usage, please use "TryIt" as the license code.
  oSmtp.LicenseCode = "TryIt"
 
  oSmtp.ServerAddr = "mail.adminsystem.net"
  
  'user authentication
  oSmtp.UserName = "test@adminsystem.net"
  oSmtp.Password = "test"
  
  'If your server requires SSL connection
  'oSmtp.SSL_init
  'oSmtp.SSL_starttls = 0
  'oSmtp.ServerPort = 465
  
  ''If your server requires TLS connection
  'oSmtp.SSL_init
  'oSmtp.SSL_starttls = 1
  'oSmtp.ServerPort = 25
  
  oSmtp.FromAddr = "test@adminsystem.net"
  oSmtp.AddRecipient "Support Team", "support@adminsystem.net", 0
 
  oSmtp.Subject = "Test"
  oSmtp.BodyText = "Hello, this is a test...."
 
  If oSmtp.SendMail() = 0 Then
    MsgBox "Message delivered!"
  Else
    MsgBox oSmtp.GetLastErrDescription()
  End If
End Sub

[JScript/WSH]
function SendEmail()
{
  var oSmtp = new ActiveXObject("EASendMailObj.Mail");
  //The license code for EASendMail ActiveX Object,
  //for evaluation usage, please use "TryIt" as the license code.
  oSmtp.LicenseCode = "TryIt";  
  
  oSmtp.ServerAddr = "mail.adminsystem.net";
  
  //user authentication
  oSmtp.UserName = "test@adminsystem.net";
  oSmtp.Password = "test";
  
  //If your server requires SSL connection
  //oSmtp.SSL_init();
  //oSmtp.SSL_starttls = 0;
  //oSmtp.ServerPort = 465;
  
  //If your server requires TLS connection
  //oSmtp.SSL_init();
  //oSmtp.SSL_starttls = 1;
  //oSmtp.ServerPort = 25;
    
  oSmtp.FromAddr = "test@adminsystem.net";
  oSmtp.AddRecipient( "Support Team", "support@adminsystem.net", 0 );
 
  oSmtp.Subject = "Test";
  oSmtp.BodyText = "Hello, this is a test....";
  
  if( oSmtp.SendMail() == 0 )
    WScript.Echo( "Message delivered!" );
  else
    WScript.Echo( oSmtp.GetLastErrDescription());
}

[Visual C++]
#include "stdafx.h"
#include <comdef.h>
#include <iostream>

#include "easendmailobj.tlh"
using namespace EASendMailObjLib;

using namespace std;
 
void SendEmail()
{
  ::CoInitialize( NULL );
  IMailPtr oSmtp = NULL;
  oSmtp.CreateInstance("EASendMailObj.Mail");
	
  //The license code for EASendMail ActiveX Object,
  //for evaluation usage, please use "TryIt" as the license code.
  oSmtp->LicenseCode = _bstr_t("TryIt");
	
  oSmtp->ServerAddr = _bstr_t( "mail.adminsystem.net" );

  
  // user authentication
  oSmtp->UserName = _bstr_t("test@adminsystem.net");
  oSmtp->Password = _bstr_t("test");
  
  //If your server requires SSL connection
  //oSmtp->SSL_init();
  //oSmtp->SSL_starttls = 0;
  //oSmtp->ServerPort = 465;
  
  //If your server requires TLS connection
  //oSmtp->SSL_init();
  //oSmtp->SSL_starttls = 1;
  //oSmtp->ServerPort = 25;  
  
  oSmtp->FromAddr = _bstr_t( "test@adminsystem.net" );
  oSmtp->AddRecipient( _bstr_t("Support Team"), 
                          _bstr_t("support@adminsystem.net"), 0 );
 
  oSmtp->Subject = _bstr_t("Test");
  oSmtp->BodyText = _bstr_t("Hello, this is a test....");
  
  if( oSmtp->SendMail() == 0 )
    cout << "Message delivered!" << endl;
  else
    cout << (const char*)(oSmtp->GetLastErrDescription()) << endl;
}

See Also

Using EASendMail ActiveX Object
Work with EASendMail Service(Mail Queuing)
How to use DomainKeys Signature
Send email without SMTP server(DNS lookup)
Mail vs. FastSender
Programming with Asynchronous Mode
Digital Signature and Email Encryption
Work with RTF and Word
Programming with FastSender
EASendMail ActiveX Object References
EASendMail SMTP Component Samples