Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

SMTP Error - Sending Mail from NAV

Posted on by Microsoft Employee

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

  • Suggested answer
    TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: SMTP Error - Sending Mail from NAV

    Glad you found the solution.

    I also agree with Joathan. If I am not mistaken if you set the user email, then u don't have to specify the from address. NAV will take it from the user.

  • Community Member Profile Picture
    Community Member Microsoft Employee 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.

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

    Thanks....this works.

  • Verified answer
    RobertasR Profile Picture
    RobertasR 5,002 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

  • Community Member Profile Picture
    Community Member Microsoft Employee 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
    keoma Profile Picture
    keoma 32,675 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.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 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.

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

    Yes, it is there.

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

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

  • Community Member Profile Picture
    Community Member Microsoft Employee 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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans