Monique wrote:qais wrote:Dear All,
I found a solution
HEREThanks
Hello Qais or anybody else who can help me....
I have looked at the solution you provided, but I don't know exactly where to put that code from the article. I am a beginner in programming, so if you could help me out a bit, I would be very gratefull.
The error I get when emails have to be sent to customers is:
Error sending e-mail. Onjuiste reeks opdrachten. Het serverantwoord is: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.
Thanx in advance!
Monique Rodenburg
Hi Monique Rodenburg,
This code is valid for NopCommerce1.10 and working 100%, I didn't try it in version 1.11
1. open the file
NopCommerce1.10\Nop.Common\Messages\MessageManager.cs2. put this code inside it
const string SuccessCode = "+OK";
const int TimeoutMs = 15 * 1000;
static void DoPopAuth(string host, string user, string passphrase)
{
TcpClient cli = new TcpClient();
cli.ReceiveTimeout = TimeoutMs;
cli.SendTimeout = TimeoutMs;
cli.Connect(host, 110);
using (Stream peer = cli.GetStream())
{
StreamWriter wtr = new StreamWriter(peer); // ASCII?
Debug.Assert("\x000D\x000A" == wtr.NewLine, "CRLF!");
StreamReader rdr = new StreamReader(peer); // ASCII?
String line;
//
line = rdr.ReadLine();
if (line == null)
throw new EndOfStreamException("Closed by peer at: Connect");
Debug.WriteLine("Received: '{0}'", line);
if (!line.StartsWith(SuccessCode, StringComparison.Ordinal))
throw new InvalidOperationException("Error at connect: '" + line + "'");
// TODO check if host supports APOP. Regex(".*{<.*@.*>}");
//
wtr.WriteLine("USER {0}", user);
wtr.Flush();
line = rdr.ReadLine();
if (line == null)
throw new EndOfStreamException("Closed by peer at: USER");
Debug.WriteLine("Received: '{0}'", line);
if (!line.StartsWith(SuccessCode, StringComparison.Ordinal))
throw new InvalidOperationException("Error on USER: '" + line + "'");
//
wtr.WriteLine("PASS {0}", passphrase);
wtr.Flush();
line = rdr.ReadLine();
if (line == null)
throw new EndOfStreamException("Closed by peer at: PASS");
Debug.WriteLine("Received: '{0}'", line);
if (!line.StartsWith(SuccessCode, StringComparison.Ordinal))
throw new InvalidOperationException("Error on PASS: '" + line + "'");
// If we got here success!
}
}
3. put this line of code
DoPopAuth(AdminEmailHost, AdminEmailUser, AdminEmailPassword);
before this line
smtpClient.Send(message);