Web Connection
SMTP drama
Gravatar is a globally recognized avatar based on your email address. SMTP drama
  Michael B
  All
  Dec 2, 2020 @ 02:09pm

Hi Rick,

I have been having some smtp drama on a production server. On my dev server (win 2012 latest patches and latest version of dot net bridge and wc.dll) - I am able to relay mail no problem via various domains using different mail servers.

However on an important production server of ours, we are not able to relay the mail. The software versions and configuration are the same, it just wont go. As far as what's different, the machine is behind a hardware firewall, however all ports are in fact allowed on the outbound.

I should also mention, it did not 'never' work. It recently stopped working.

You mentioned in one of your articles that the smtp send via dot net bridge uses some standard .net lib. What is the best way to debug this?

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Rick Strahl
  Doug Hennig
  Dec 2, 2020 @ 10:16pm

I'm curious:

What issues were you actually having with SMTPClient? The reason Microsoft no recommends it is because:

  • It's not cross platform (ie. doesn't work on all supported .NET Core platforms)
  • Multi-threading issues

Neither of these should be a concern for FoxPro.

I ask because I use it quite heavily both in Fox (via wwSmtp) and .NET to send a lot of emails (like messages from this message board for example) and really haven't seen any issues.

That said - just took a look at MailKit and one thing that looks useful is that it also include POP3 support which would allow updating the wwPop3 class that's been pretty much abandoned some time ago 😃 There are certainly more features (more auth themes mainly) but other than that I don't really see anything that stands out that provides better support for anything.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Doug Hennig
  Rick Strahl
  Dec 3, 2020 @ 05:58am

In the docs for SMTPClient (https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient?view=net-5.0), I saw this: "We don't recommend that you use the SmtpClient class for new development because SmtpClient doesn't support many modern protocols." That jived with what I was finding: several customers were having problems connecting to their mail server and SMTPClient's error messages were less than helpful. I tried using MailKit and the problems went away.

Now, in hindsight, it could also due to the fact that I had built my SMTPClient wrapper for .NET 4, which doesn't support TLS 1.2.

Another benefit of MailKit, though, is that it supports logging the messages between the client and the mail server, which I've found useful a few times for debugging issues.

Doug

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Rick Strahl
  Doug Hennig
  Dec 3, 2020 @ 12:59pm

Right - that's why I asked. wwSmtp is used by a lot of people and I see very little in the way of problems. Most of the problems that do crop up are due to service or access restrictions (like with GMail business accounts) rather than actual connection problems. Lack of support for decent logging is a pain - that can be super useful and was one thing my old native Win32 code was able to do. But overall SmtpClient has not given me any problems that made me think I needed to switch.

Looking over MailKit's features though, I am thinking it might not be a bad idea to switch to it as well because it does support SMTP, IMAP and POP3. Downside is extra library requirement.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Michael B
  Rick Strahl
  Dec 4, 2020 @ 06:26am

Rick and Doug,

Are either of you able to send mail and change the cReplyTo from WWWC and have it work? I am not. My platform is a SaaS used by many different companies. For 20 years we allowed our customers to use OUR smtp server. We would use a single mailbox for sending mail and we would allow the 'from name and email' to be our clients. You are both likely shaking your head, saying 'that does not work anymore' which I would agree. It MOSTLY does not work any more.

At the moment the only way to send mail via wwSmtp (.net mode) is to use the EXACT authentication mailbox address as the 'sender email' to get messages through. The replyto email is getting ignored entirely. I have tested on office 365 and rackspace so far.

It seems the most reasonable solution is a paid account via mailgun or sendgrid. I have 'reasonable' success with these platforms.

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Rick Strahl
  Michael B
  Dec 4, 2020 @ 11:10am

Sure - the email for this message you're getting has a reply-to and AFAIK that works. Message is addressed from the Message Board account and the reply to is noreply@west-wind.com.

The protocol works fine. The issue most likely is that mail providers are stripping that out when sending to avoid phishing attacks.

I use MailGun for sending messages here and a reply-to extra header.

IOW, that's not a problem with the software - that's a problem with the provider you're having.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Michael B
  Rick Strahl
  Dec 5, 2020 @ 10:03am

Rick as you suspected, it was a third party config causing the trouble, but not the usual suspect. The system admin where the WWWC app lived wrote me this in a message this am "The outgoing IP wasn't always mapping to the proper external IP. I reconfigured the NAT for the WWWC server and confirmed that outside sites/servers see the traffic is coming from 999.999.999.999 (obfuscated for obvious reasons)".

So the message here is that when sending email you cannot spoof the ip address from the sender without running into an inability to send mail.

For what it's worth my platform still cannot send email via any smtp server OTHER THAN sendgrid. That implementation is still using the .net mode in WWWC via a send grid smtp server though on port 587. However, a traditional smtp server like rackspace or office 365 is NOT allowing me to send.

The software works fine on a windows server that is not behind a nat.

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Rick Strahl
  Michael B
  Dec 5, 2020 @ 01:51pm

That's because those services ensure that you're sending using an account that goes with the domain usually.

GMail, Outlook/Office365 are not good services to use for service emails because they are super strict on what they allow based on domain you're sending from IP address b locks that are possibly blacklisted etc. There are also severe restriction on the volume you're allowed to send.

if you need to send emails from an application I'd highly recommend using some sort of service. SendGrid and MailGun have free accounts for a reasonable number of emails and somewhat reasonable pricing for larger volume sends. It's well worth it to not have to worry about this shit with Gmail/Outlook etc. Private servers too are problematic as they almost certainly will end up on blacklists.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Jim Day
  Rick Strahl
  Oct 30, 2022 @ 07:01pm

are SendGrid and MailGun still your choice for a mail server? Looks like mailgun is now $35 per month and not free. Does that sound correct?

Found out I am one of a few accounts on my isp's mail server and it is now blacklisted.

Thanks for your help.

Jim

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Rick Strahl
  Jim Day
  Oct 31, 2022 @ 12:29am

Yes I'm using MailGun for all of the email here on the MB and my store and licensing. I have a freemium plan (maybe grandfathered) where I pay if I go over a certain relatively low number of emails. I rarely hit that limit though and most of my bills are like $5 when I do get them.

Yeah $35/month would not be great for the small amount of emails I do, but I'm not sure if there is a good alternative these days to using one of these services given how any server you run your self will be instantly blacklisted.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Jim Day
  Rick Strahl
  Oct 31, 2022 @ 02:45pm

MailJet is the low volume free service.

I did get it set up.

Thanks, Jim

Gravatar is a globally recognized avatar based on your email address. re: SMTP drama
  Rick Strahl
  Jim Day
  Oct 31, 2022 @ 03:10pm

Most services have a free tier.

Mailgun does 5000 emails a month for free (but I think you have to give them a CC for 'overage'):

https://www.mailgun.com/pricing/

I'm not married to any one service, but I've been using MailGun for a number of years and it's been good. I would expect similar experience for any of the major mail services.

+++ Rick ---

© 1996-2022