Sending mail with ASP.net causes AuthenticationException - email

The site has been running for several years and now all of a sudden this error appears for many of the users of the site. The site is set up as MVC3 and at some point it is sending a mail to the user. Now the error appears:
AuthenticationException: The remote certificate is invalid according to the validation procedure.
I find it hard to understand issues with certificates because I dont know enough about it. Since this is happening for several users if not all, I recon there is a problem with the SSL certificate on the server.? Could someone point me in the direction of solving this problem?
The application uses Gmail smtp server with ssl and authentication for sending mails.
And also I would be very happy if someone could explain shortly how the certificate procedures are :)

Related

Sendgrid emails getting deferred

All the emails which I sent via SendGrid is getting deferred. On the SendGrid Activity dashboard it shows the message. "554 Your access to this mail system has been rejected due to the sending MTA's poor reputation. If you believe that this failure is in error, please contact the intended recipient via alternate means."
It used to work 3 months ago. For the past 3 months, there were only very few email being sent out. Now All the emails sent are getting deferred.
Please let me know a fix for this.
Thanks in advance
I think I figured it out. I'm using shared hosting of SendGrid, so the server is being used by others as well. Go to the activity overview, and click the info icon. You will see more information, in my case it's like:
...Client host [149.72.39.137] blocked using Spamhaus. To request removal from this list see https://www.spamhaus.org/query/ip/149.72.39.137...
If you click the link, you can see the reason:
So here it's obvious that some phising was going on, therefore, mails are delayed and/or blocked.
I guess to solve this, we should upgrade to have a dedicated server...

Gmail SMTP Access 5.5.1 Authentication Required. From Custom Domain

I'm trying to send emails via smtp.gmail.com in the standard way, and I'm getting a standard error, but for some non-standard reason.
Specifically, I get this error: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. when I send the mail.
The answers on this link have not helped me: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required?
I suspect that there are additional steps required if you're trying to do this from a custom domain.
I've created a throw-away standard Gmail account to test out my code and everything works perfectly there.
If I en-/dis-able Less Secure Apps then it behaves as you'd expect, and as per the linked solutions.
If I en-/dis-able 2FA and create 3rd party app passwords then, again, it behaves as I'd expect, and as per the linked solutions.
So my code, and my ability to configure a general Gamil acccount, are working just fine.
But when I use an otherwise identical GSuite email address, set up on a custom domain (system#clientdomain.co.uk) then nothing works :( I've tried all the permutations, with/without LessSecureApps, with main user password / with 3rd Party App Password, etc. Nothing works.
I can only assume that either the custom domain or the fact that it's a GSuite account is breaking it.
What now?
So apparently I either needed to wait longer, or change the settings harder!!
A colleague wandered past and asked what the problem was and I demonstrated it, including going through and setting the settings again, and this time it worked. I'm 80% sure they were the same settings, but perhaps not?

Mail routing with mailgun

I'm setting mailgun route to xx#me.com to forward an email to a server at http://xxx:7000/reply.
I tested already the email route and it's fine as well as the server is up both in browser and using curl. However sending an email to xx#me.com still nothing happens.
There is already a similar question but nobody answered:
Can't recieve incoming mail with Mailgun
There are a few requirements for handling incoming emails with Mailgun.
Your account must be verified (email/SMS message)
The domain or subdomain must be added to the account.
SPF & DKIM must be verified and have MX records configured with Mailgun's values. Details for DNS record information
Route filters configured with the recipient domain or subdomain matching. (Example: Domain "bar.com" is added to the account. The expression can match_recipient("foo#bar.com"). If a subdomain is added, then it will need to match the subdomain, e.g. match_recipient("foo#mg.bar.com"))
The error from the linked question would be due to one of the above requirements wasn't fulfilled. A rejection of "550 5.7.1 Relaying denied" from Mailgun's incoming mail servers indicates a domain or subdomain has MX records pointed toward Mailgun's but the domain does not exist within an account.
**Disclaimer I work at Mailgun
I know this is 6 months old, but since I spent 4 hours trying to figure this out, I will share my solution:
There is another cause of the 5.7.1 Relaying denied message: My mailgun account wasn't verified. I saw someone suggest this but I figured they just meant that I had to verify the address I was forwarding to. Nope, when I logged in today I saw a banner at the top saying click here to resend your verification email. I did that, it went through a text message verification process, and all immediately started working!
I know this is quite a stale thread, but I also wanted to chime in here in hopes of saving folks a few hours of their life trying to solve the "550 5.7.1 Relaying denied" caper.
For me? It was what has plagued me on several occasions. I was able to verify via Gmail > 'Settings' > 'Accounts and Import' > 'Add another email address' only after I disconnected from my software-based VPN (Private Internet Access).
[Your sigh or wince here]
Now, go get it... make it happen. ;-)
If you're using MailGun with cPanel (for example, after following this tutorial) and you're getting the 550 5.7.1 Relaying denied error, make sure you're using the MailGun SMTP credentials given after adding your domain (as opposed to your MailGun username and password as the documentation suggests). That was the origin of my own problem.
Another reason for this error code may well be that you are trying to send stuff over SMTP whereas you've indicated on the sending properties of mailgun settings for your domain that you want to use the API...

SAS (WPS) cannot send email via SMTP. See error code

I am using WPS, a diluted version of SAS, and I cannot send emails through the SMTP server using the normal (and fairly well documented) config flags.
I keep receiving the error message:
SSL exception: Could not initialise security context [80090322]
Having found some forum posts, the description for this issue is that the SMTP server is expecting authentication using a certificate. When I mentioned this to the IT team, nothing came from it. Having used SAS for a significant period, you would normally and quite simply apply some very basic information into the config file (see below).
I've been given the admin username and password, I've used an array of different ports, but still the same error message persists.
Does anyone have any ideas on how to make SAS/WPS connect to a secure SMTP? Config file is:
-emailsys SMTP
-emailhost 10.0.x.x
-emailport 23 (Port 23 was opened for my use, we are not able to use port 25).
The error message persists even if I force the credentials via -emailid and -emailpw.
Thanks in advance,
Dan
The fix for this is to utilise a fully qualified domain name, rather than an IP address or other method.
I know this is very old, but I had a really bad time trying to figure this same problem out and I'd like to post my solution here for people who might need it in the future.
Basically, this problem happens because SAS/WPS is trying to validate the certificate he has gotten from the smtp server when trying to interact with it (ie.: send an e-mail).
There are 2 solutions:
You can define the location were the trusted certificators are stored for the system to validate it.
You can define the server option TLS_HOSTVALIDATION to NONE by doing something like OPTIONS TLS_HOSTVALIDATION=NONE
I hope this helps.

Website is not sending emails to email add on MS Exhange

Having problems with setting up my website to use MS Exchange to send emails. I dont want to use the hosts email system.
The MS Exhange has been set up, with email addresses created.
My webpages are using Persits.MailSender which the host supports.
Do i need to change MX records? A records?
Sorry, im not clued up with network side of things, any help would be appreciated
When i email direct, the email address on the exchange picks up the emails. BUT if i email through the website, it goes to the annoying webmail the host is provinding, and not to the exchange
I find this strange, the same email address receiving emails at different places!
Im using ASP, and I have a website set up, which has been sending emails for the last 12 months, the host has messed up (again) somewhere, but doesnt know what is wrong (as usual)
There are no errors, the email always gets sent.... but to the wrong place.
I would look into actually trapping and knowing your errors. That way you can see precisely why it fails and have something to work with. As it stands, your question isn't really answerable. No language nor framework is provided. We don't know if the mail server is confirmed to be working or accessible outside your netowrk; we don't know how your are referencing it or if you are passing user credentials; we don't know what error you're getting...
At this point, you're not debugging, you're just sort of swinging in the dark. Find the point of failure and then research that data point to get a solution. Debug, catch errors, log, step through your code. All good ideas.
Ok i figured it out, I deleted the mail domain on the host as that was the first place the website looks to send an email. Once the mail domain was deleted the emails were sent to the external hosted mailserver MS Exchange email address. Yay!