SMTP error when 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())
{   // 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;
if (fileAttachment != null)
ReportLog(trfid, msgStr, EventLogEntryType.Information, 1000, Actions.Internal);
catch (SmtpException ex)


edited 11/28/2017 4:01:17 PM
asked 5/21/2014 9:55:03 PM
add a comment

1 Answers


Please make sure the sender email address matches the SMTP account on your SMTP server. They may not require you to authenticate but the email addresses must match.

answered 11/16/2017 12:41:37 AM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged smtp or ask your own question.