web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

SMTP Error - Sending Mail from NAV

(0) ShareShare
ReportReport
Posted on by

Hi,

I wrote a report using HTML stuff to compile the data and send that as table through Email. Everything is good except that i am getting following error,

The SMTP mail system returned the following error: "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM

SMTP-setup.png

This is the SMTP setting in NAV.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RobertasR Profile Picture
    5,004 on at
    RE: SMTP Error - Sending Mail from NAV

    Hi,

    please check if you have defined the Sender Email when creating the message (when calling smtp.CreateMessage function)

    Robertas

  • Community Member Profile Picture
    on at
    RE: SMTP Error - Sending Mail from NAV

    Hello,

    yes, ofcourse i did specify recepient. om SMTP setup, when i send test Email(Test Email Setup), it works only for the id that we specify on User ID Field. I have checked with few Users IDs and all giving the same error when sending Emails to other id.

  • RobertasR Profile Picture
    5,004 on at
    RE: SMTP Error - Sending Mail from NAV

    Hi, not the Recipient, but the Sender is in question.

  • Community Member Profile Picture
    on at
    RE: SMTP Error - Sending Mail from NAV

    Yes, it is there.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,241 Super User 2025 Season 2 on at
    RE: SMTP Error - Sending Mail from NAV

    Please send us the code you are using for sending the email. It looks like you are not using the sender address while sending the email.

  • Verified answer
    keoma Profile Picture
    32,729 on at
    RE: SMTP Error - Sending Mail from NAV

    check if there is a mail address set in usersetup for the users.

    check if the mail addresses can be used with the used smtp server (valid accounts).

    check if account/password are valid for login at the used smtp server.

  • Community Member Profile Picture
    on at
    RE: SMTP Error - Sending Mail from NAV

    Hi,

    The Sender and receipient both are there.

    Below is the Code,

    Purch. Rcpt. Line - OnPreDataItem()

    CLEAR(SMTPMail);

    SMTPSetup.GET;

    //SETRANGE("Posting Date",WORKDATE);

    Recipients:= 'ABC@CorpXY.com';

    Subject := 'Expense Receipt Notification' + ': ' + FORMAT(WORKDATE);

    Body := 'Following Items are received on :' + FORMAT(WORKDATE);

    CLEAR(SMTPMail);

    SMTPMail.CreateMessage('XYZ',SMTPSetup."User ID",Recipients,Subject,'',TRUE);

    SMTPMail.AppendBody('Hello,');

    SMTPMail.AppendBody('<br><br>');

    SMTPMail.AppendBody('<h1>'+ Body + '</h1>');

    SMTPMail.AppendBody('<br><br>');

    SMTPMail.AppendBody('<table border="1">');

    SMTPMail.AppendBody('<tr>');

    SMTPMail.AppendBody('<th><b>Document No.</th>');

    SMTPMail.AppendBody('<th><b>Order No.</th>');

    SMTPMail.AppendBody('<th><b>Item No.</th>');

    SMTPMail.AppendBody('<th><b>Description</th>');

    SMTPMail.AppendBody('<th><b>Quantity</th>');

    SMTPMail.AppendBody('<th><b>Unit Cost(LCY)</th>');

    SMTPMail.AppendBody('<th><b>Amount(LCY)</th>');

    SMTPMail.AppendBody('</tr>');

    Purch. Rcpt. Line - OnAfterGetRecord()

    SMTPMail.AppendBody('<tr>');

    SMTPMail.AppendBody('<td>' + FORMAT("Document No.") + '</td>');

    SMTPMail.AppendBody('<td>' + FORMAT("Order No.") + '</td>');

    SMTPMail.AppendBody('<td>' + FORMAT("No.") + '</td>');

    SMTPMail.AppendBody('<td>' + FORMAT(Description) + '</td>');

    SMTPMail.AppendBody('<td>' + FORMAT(Quantity) + '</td>');

    SMTPMail.AppendBody('<td>' + FORMAT("Unit Cost (LCY)") + '</td>');

    SMTPMail.AppendBody('<td>' + FORMAT("Unit Cost (LCY)" * Quantity) + '</td>');

    SMTPMail.AppendBody('</tr>');

    Purch. Rcpt. Line - OnPostDataItem()

    SMTPMail.AppendBody('</table>');

    SMTPMail.AppendBody('<br><br>');

    SMTPMail.AppendBody('Thanks ');

    SMTPMail.AppendBody(' ');

    SMTPMail.AppendBody('<br><br>');

    SMTPMail.AppendBody('<hr>');

    SMTPMail.AppendBody('This is system generated mail. Please do not reply to this mail id.');

    SMTPMail.Send;

    When i use my ID as user Id in SMTP setup, its working but when i give a particular Notification id, than we have the above error. but this ID is working fine when sending Approval Emails with in NAV.

  • Verified answer
    RobertasR Profile Picture
    5,004 on at
    RE: SMTP Error - Sending Mail from NAV

    Hi,

    when you create the message (extract from your code):

    SMTPMail.CreateMessage('XYZ',SMTPSetup."User ID",Recipients,Subject,'',TRUE);

    the second parameter has to be an actual e-mail, and you're passing the User ID. What you need to do is something along those lines:

    UserSetup.GET(SMTPSetup."User ID");

    UserSetup.TESTFIELD("E-Mail");

    SMTPMail.CreateMessage('XYZ',UserSetup."E-Mail",Recipients,Subject,'',TRUE);

    Hope that helps.

    Robertas

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: SMTP Error - Sending Mail from NAV

    Thanks....this works.

  • Community Member Profile Picture
    on at
    RE: SMTP Error - Sending Mail from NAV

    Sorry, yes this works ...thanks Robertas.  Please ignore my below post. now i understand the concept.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans