question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't send email on production server.

See original GitHub issue

Describe the bug I tested on local server and used gmail smtp.gmail.com OR company email, it’s worked email send.

But when i release production to customer web server, Email not send and don’t have any error exception.

1) How i can check some service on customer web server are block send email ? 2) I can check the status of the result when send email (complete / failed) ?

Sample on code:

using (var client = new MailKit.Net.Smtp.SmtpClient())
            {
                await client.ConnectAsync(sSmtp, nPort, false);

                // Note: since we don't have an OAuth2 token, disable
                // the XOAUTH2 authentication mechanism.
                client.AuthenticationMechanisms.Remove("XOAUTH2");
                client.AuthenticationMechanisms.Remove("CRAM-MD5");
                client.AuthenticationMechanisms.Remove("DIGEST-MD5");
                await client.AuthenticateAsync(sTemplateEmailEmailFrom, sAuthenPassword);

                try
                {
                    client.Send(message);
                    System.IO.File.WriteAllText("C:\\Temp\\NoError.txt","Send");
                }
                catch (SmtpCommandException ex)
                {
                    Console.WriteLine("Error sending message: {0}", ex.Message);
                    Console.WriteLine("\tStatusCode: {0}", ex.StatusCode);

                    switch (ex.ErrorCode)
                    {
                        case SmtpErrorCode.RecipientNotAccepted:
                            Console.WriteLine("\tRecipient not accepted: {0}", ex.Mailbox);
                            break;
                        case SmtpErrorCode.SenderNotAccepted:
                            Console.WriteLine("\tSender not accepted: {0}", ex.Mailbox);
                            break;

                        case SmtpErrorCode.MessageNotAccepted:
                            Console.WriteLine("\tMessage not accepted.");
                            break;
                    }
                }
                catch (SmtpProtocolException ex)
                {
                    Console.WriteLine("Protocol error while sending message: {0}", ex.Message);
                }
                client.Disconnect(true);
                System.IO.File.WriteAllText("C:\\Temp\\DiscountTrue.txt", "DiscountTrue");
            }
        }

Screenshots I checked on telnet on customer web server image

image

Other information on server:

  • OS: Windows Server 2008 R2 Standard SP1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jstedfastcommented, May 30, 2019

Don’t use smtp.gmail.com if you don’t know how to get it working.

GMail blocks you from sending mail unless it recognizes your IP address from a previous login via a web browser.

I don’t know all of the details so I can’t help you. You’ll have to do some google searches and figure it out.

0reactions
skashif18commented, Dec 25, 2022

for me also it’s not working on the production server, I am using my company mail, and the strange thing is there is no error or exception coming.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can't send email on production environment
Mails are sent perfectly in others environments except in production environment. Try logging into the production server(s) and attempt to ...
Read more >
Email not sending - Things to do to solve sending issues
Issues concerning email sending are pretty common. Discover how to solve them.
Read more >
Cannot send emails: How to fix email sending issues
Cannot send emails : How to fix email sending issues · Check your internet connection. · Check your SMTP server details. · Verify...
Read more >
Laravel sending mail not working on production server
Hello All, Whenever I try to send mail to a user my app sends mail to the log file even after changing driver...
Read more >
Cannot configure SMTP for outgoing mail on production ...
Hi. So Configuring Outgoing Email in local works fine (Windows 10, 64 bits) and we are able to send emails but we have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found