Reputation: 887
Recently I had to move one of my web applications to a new hosting provider. The mail and web service is still held on the old hosting site however, when I try to send an email from the new server,I get an error;
"The server rejected one or more recipient addresses. The server response was:
450 <email_address>: Recipient address rejected: Greylisted for 5 minutes
I asked my old hosting provider what I need to do to fix this and they replied with
The mail server operates on POP before SMTP. If a valid POP login is not received before sending mail through the server, then the mail is greylisted and held for 5 minutes before a retry.
To prevent this, simply do a Receive before sending mail
Does anyone have any idea how I do a POP before SMTP in C#?
Upvotes: 2
Views: 1743
Reputation: 10502
You already have the code you're looking for, but if I may add in my thoughts: Like someone else already suggested, I would check with the old provider whether they provide AUTH with SMTP. To me, what they are saying is that, "You can use SMTP only if you are coming from the same IP range/subnet, or if you have authenticated yourself". A lot of ISPs do this with their SMTP servers. If you are connected through a particular ISP, you can use the SMTP without providing any AUTH credentials explicitly. If you switch to another ISP and want to use the old ISP's SMTP, you'll have to explicitly authenticate with the SMTP server.
Upvotes: 1
Reputation: 887
As suggested I added the code to my blog. It's not the best blog ever published but, someone may find it useful... POP-Before-SMTP
Upvotes: 1
Reputation: 887
I managed to write the code for this. I am willing to share the solution, (if anyone is interested?) but not sure how best to put the code on Stackoverflow? It's about 50 lines of code.
Upvotes: 1
Reputation: 10062
I'm pretty sure POP3 is not built into the .NET Framework, so you'll need to implement it yourself as Owen suggested or look for an existing POP3 library such as this one.
Even better would be convincing your new hosting provider to relax that greylisting rule.
Upvotes: 1
Reputation: 24624
They greylist you because you connect from your new provider, right? Doesn't the new provider have a SMTP which allows connections from the servers IP-range?
Another approach is to do the MX-lookup yourself, and connect directly to the authoritive SMTP-server for which address you're sending email to. However, that also requires you to handle greylisting, meaning, retries on 4xx responses in order to have a reliable delivery.
Maybe you should ask your provider if they provide auth SMTP as an alternative aswell, it's kind of another possible point of failure with the need of POP-login before using the SMTP-service.
Upvotes: 1
Reputation: 84513
i'm not sure how C# would handle the specifics (sockets?), but basically you just want to make a connection to your new POP server. here's a sample POP transaction:
$ telnet new-pop-server.com 110
Connected to new-pop-server.com.
Escape character is '^]'.
+OK
USER <username>
+OK
PASS <password>
+OK // you're authenticated at this point
LIST
+OK
. // no new messages!
QUIT
+OK
once you're authorized you should be able to send your mail programatically. (USER, PASS, LIST, QUIT) are all commands you would send (pop3 RFC).
Upvotes: 2