I created a simple application at: graficaromana.com.br
In the contact form (http://graficaromana.com.br/Contato) when I try to send an email I get an error.
Locally the mail is sent normally without any error.
Is there some setting I have to do on the host? in the domain?
Error:
System.Net.Sockets.SocketException A connection attempt failed because
the connected party did not properly respond after a period of time,
or established connection failed because connected host has failed to
respond 209.85.225.108:25
See the code for more details in link: https://gist.github.com/1149028
looks like the remote host has maybe a separate server they use for sending mail out or that you have to be whitelisted with the host in order to send mail and a username and password may be required. have not looked at your code but i see them kind of errors when there is a firewall involved and the machine trying to send does not have access through the firewall, as the firewall does not respond at all you get an answer like ' The server did not respond in a timely manner' or 'the server did not respond after a certain amount of time' i am assuming that before you posted on here that you have asked the hosting provider about sending mail, and what there preference is on how this should be carried out? right?
if so please provide info on what they have said
here is a sample of code to send email:
var smtpClient = new SmtpClient();
var message = new MailMessage();
smtpClient.port = 25;
message.from = "test#test.com";
message.To.Add("me#workemail.com,client#office.com";
message.Subject = "Contact from website";
message.IsBodyHtml = true;
message.Body = "<html><head></head><body>TEST</body></html>"
try {
smtpClient.Host = "relay.server.you.have.from.host";
smtpClient.Send(message);
} catch( Exception ) {
// host is down or we are local try other servers
// here you can have more try / catch
smtpClient.Host = "127.0.0.1"
smtpClient.Send(message);
}
Related
I have an electron app that creates a websocket connection to a node js server. It sends a JSON request to that server telling it to create a xmpp client.
let message = {
action: "setupXmpp",
data: {
username,
password,
},
};
socket.send(JSON.stringify(message));
Within that server I have a switch that reads the message action and creates the xmpp client. The code in xmppActions is standard boilerplate taken from xmpp's repo
const xmppActions = require("./Webapp/xmppActions");
case "setupXmpp":
console.log(`Received setupXmpp request`);
var { username, password } = message.data;
const xmpp = xmppActions.setUpXMPPconn(username, password);
xmpp.on("online", async (address) => {
console.log("▶", "online as", address.toString());
ws.send("Register xmpp Success!");
});
break;
Everything works fine I can create an xmpp client and send messages, all good.
My issue is when i have two clients open and they both register (with different username and password ) whoever is the last request always overrides the previous register. I've done a wireshark trace and the two websocket connections are created as I would expect but when it comes to sending messages they both use the most recent register. I assume it's because the XMPP client is a constant and whoever is last it uses those for all future requests.
How do I make it so that each websocket connection gets its own XMPP client almost like a request scoped client specific for each websocket.
I had a constant outside the websocket connection, changed it to have a var inside so each connection had it own client.
I am creating a system that sends emails (pricing, orders, invoices, etc) to out customers. But due to the number of emails that ends up being, we hit limits when trying to send through gmail or any other mail client. And since these are all customer specific emails using a bulk sending client is not ideal.
So I have created a system using mailkit and others to send our emails from our own servers without needing to set up a relay or email server for sending. This works great with everyone (Gmail, outlook, etc) except for yahoo. For some reason when I connect and mailkit tries to switch to STL (via startstl) yahoo sends garbage and mail kit fails.
I have enabled all ssl and tsl protocols. And I have ServerCertificateValidationCallback always to return true. In fact ServerCertificateValidationCallback doesn't even get called.
The errors that are thrown start with:
A call to SSPI failed, see inner exception
then
The message received was unexpected or badly formatted.
If I try to connect to any of the other SMTP ports 465 or 587 the system just hangs.
This all happens when connecting, before the email is sent. So it cannot be a DKIM issue. And the SPF record is set up correctly. We don't have the reverse dns setup because we plan on sending from multiple servers with different IPs.
I don't know why yahoo is being so difficult.
Tried talking with MailKit, tries allowing all TLS and SSL connections. Tried finding any YAHOO support.
using (var client = new SmtpClient())
{
client.LocalDomain = "MyDomain";
// right now we don't care about all SSL certificates (in case the server supports STARTTLS)
client.ServerCertificateValidationCallback = (s, c, h, e) => {
return true;
};
client.SslProtocols = System.Security.Authentication.SslProtocols.Tls11 |
System.Security.Authentication.SslProtocols.Tls12 |
System.Security.Authentication.SslProtocols.Tls |
System.Security.Authentication.SslProtocols.Ssl3 |
System.Security.Authentication.SslProtocols.Ssl2;
client.CheckCertificateRevocation = false;
client.Connect("mta6.am0.yahoodns.net", 25, false); //<--- fails here
client.Send("test", fromMailBoxAddress, recipientsEmailBoxAddresses);
client.Disconnect(true);
}
To answer your question, I might have an idea why Yahoo is being so difficult - it's possibly your message construction. Verify your MimeMessage has the same exact email address for your From and Sender addresses. Ensure your ReplyTo only contains the Sender email address. I had both the sender and recipient email addresses in the ReplyTo and Yahoo did NOT like that. And, of course, you are using a Yahoo App password for authentication. Once I made these two changes, Yahoo sent the email successfully.
Settings
client.SslProtocols = System.Security.Authentication.SslProtocols.Tls12;
client.DeliveryStatusNotificationType = mail.DeliveryStatusNotificationType.Full;
await client.ConnectAsync("smtp.mail.yahoo.com", 587, SecureSocketOptions.StartTls);
await client.AuthenticateAsync(yourEmailAddress#yahoo.com, yourYahooAppPassword);
await client.SendAsync(Message);
await client.DisconnectAsync(true);
Research
Bad message construction breaks one of Yahoo's many policies. This was ONLY happening with SMTP via Yahoo. SMTP via Gmail and Outlook work fine. I kept comparing a simple MailMessage with MimeMessage message construction. MailMessage sent, MimeMessage failed, I kept getting a 550 request failed; mailbox unavailable response from Yahoo every time with my MimeMessage. I verified by using ProtocolLogger. My From was empty and that is one issue, and, I had the recipient in my ReplyTo. If I merely added the sender to the ReplyTo, it still throws that same 550 error. I had to ensure the sender was the only email in the ReplyTo.
Hope this helps.
Use client.Connect("mta6.am0.yahoodns.net", 25, SecureSocketOptions.None); if you want to disable STARTTLS or use client.Connect("smtp.mail.yahoo.com", 587, SecureSocketOptions.Auto); which works fine.
Not sure where you are getting "mta6.am0.yahoodns.net" from, but I can't even make a normal socket connection to that address.
I've created asp.net web-api , In the controller I try to call an external URL to send sms(the sms URL I get from the sms provider company )
When I try to call the controller I get this error
"The remote name could not be resolved"
This error only happened on the server ,On the localhost it's working fine
I am using Azure hosting
I tried to add some code to the webconfig
<defaultProxy enabled="true" useDefaultCredentials="true">
I also tried to call the sms URL in a different way
HttpClient client = new HttpClient();
response = client.GetAsync(urlParameters);
I've read some solutions about allowing access for the external link(SMS) on firewall and DNS of the server but it's already configured on azure server
Here is my code
string webAddress = "http://----------------";
string SomeData = System.Text.Encoding.Default.GetString((new
System.Net.WebClient()).DownloadData(webAddress));
I want my web api to send the sms without any error on the server side
Finally ,I solved the problem by replacing the SMS provider URL by their IP Address.
Here is an example of my solution :
Ex : http://123.123.123.123:12345/TEST/Para?i1=
Everything works perfectly until our mail server goes offline. But when the mail server cannot be reached our scripting fails. When a user logs into the website th server sends a notice to admin by email. But if the mail server is offline that login fails and returns a server error.
We are using CDOSYS and using the local SMTP server to relay to our main mail server. The code is straightforward...
Set ObjSendMail = CreateObject("CDO.Message")
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = artiscart_mail_server
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
ObjSendMail.Configuration.Fields.Update
ObjSendMail.To = strEmail
ObjSendMail.Subject = "Login activity"
ObjSendMail.From = strEmail
ObjSendMail.TextBody = strEmailBody
ObjSendMail.Send
Set ObjSendMail = Nothing
A similar thing happens when we send a newsletter and one of the emails is a dud. On Windows Server 2003 we had no problems whatsoever, but on Windows Server 2008 the same scripting fails.
Is there some way that I can configure the local SMTP server to ignore errors and move on?
To avoid all errors caused by mail server failure and bad email addresses, simply add this first line above the last line like so...
On Error Resume Next
ObjSendMail.Send
I have created a web service in gsoap, but server does not accept requests. There is no error, but i dont understand why it does not accept requests from client. I am pasting my client and server code here.
Clientcode
EnrollmentServiceSOAPProxy proxy;
_ns1__performRequest *req = new _ns1__performRequest();
_ns1__performRequestResponse *res = new _ns1__performRequestResponse();
if(proxy.performRequest(req, res) == SOAP_OK)
print "OK" // pseudo code for print.
else
print "Not Ok"
Server Code:
int __ns1__performRequest(soap *, _ns1__performRequest *ns1__performRequest, _ns1__performRequestResponse *ns1__performRequestResponse)
{
ns1__performRequestResponse->jobID = "1011";
return SOAP_OK;
}
The server is listening on localhost. but the request does not reach the server.
This is the WSDL file:https://www.dropbox.com/s/n2sdv51qmttp7vb/EnrollmentService.wsdl
I debugged the code, but it did not help me.
It happend with me before. In service definition i used different port, while the server was listening to different port. This seems your problem too.
The service endpoint may not be set to your server, but to whatever the WSDL defines as the server address. You should use EnrollmentServiceSOAPProxy proxy("URL"); with the URL that is your server's endpoint address (http://hostaddr or http://localhost:8000 when you run your server local on port 8000).