Subject: SMTP error when calling using anonymous
Date: 2014-05-21 21:55:03
From: Mike Tod
Source: smtp-error-calling-using-anonymous
----------------------------------------------------------------------

I'm trying to send a message to an internal SMTP server using anonymous.

My understanding is that I should only need to remove the client.Authenticate(SmtpUserID, SmtpPassword); call to send it via anonymous.

I keep getting the following error : Client was not authenticated (530).

Code example:

[code lang='c#']
// Create a new instance of the SmtpClient class.
using (SmtpClient client = new SmtpClient())
{
try
{   // Connect to the server.
client.Connect(SmtpServerAddress, SmtpPort);
// test for anonymous login
if (!String.IsNullOrEmpty(SmtpUserID))
{
client.Authenticate(SmtpUserID, SmtpPassword);
}
 
 
// Create a new mail message.
MailMessage msg = new MailMessage();
msg.Subject = @subjectStr;
msg.Priority = Priority;
msg.BodyText = @bodyStr;
msg.From.Add(SmtpFromUserID);
msg.To.Add(toAddress);
if (fileAttachment != null)
{
msg.Attachments.Add(fileAttachment);
}
 
client.Send(msg);
client.Disconnect();
ReportLog(trfid, msgStr, EventLogEntryType.Information, 1000, Actions.Internal);
}
catch (SmtpException ex)
{
....
}
}

[/code]

---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index