Hello my name is Prince...im trying to implement a register module to send a confirmation email to my client email address in asp.net. I'm using SMTP client to implement this. I used the following code:
using (SmtpClient smtp = new SmtpClient())
{
using (MailMessage mm = new MailMessage("onukwilip#gmail.com", Email.Text.Trim()))
{
mm.Subject = "Dummy";
mm.Body = "Body";
mm.IsBodyHtml = false;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential credit = new NetworkCredential("onukwilip2006#gmail.com", "onukwilip2006+_");
smtp.UseDefaultCredentials = true;
smtp.Credentials = credit;
smtp.Port = 587;
smtp.Send(mm);
}
}
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"Mail sent successfully\");", true);
i used the above function in my button onclick, but when i send the smtp is telling me:
Service not available, closing transmission channel. The server response was: Service not available
I've set my settings in account.google.com to allow less secure apps or something like that but the smtp is still not working.
It was telling me the below text the night before.
Service not available, closing transmission channel. The server response was: Too many connections
But now its telling me the below code this night.
Service not available, closing transmission channel. The server response was: Service not available
I also tried using the below function, but its still not working:
using (MailMessage mm = new MailMessage("onukwilip#gmail.com", Email.Text.Trim()))
{
mm.Subject = "Dummy";
mm.Body = "Body";
mm.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential credit = new NetworkCredential("onukwilip2006#gmail.com", "onukwilip2006+_");
smtp.UseDefaultCredentials = true;
smtp.Credentials = credit;
smtp.Port = 587;
smtp.Send(mm);
}
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"Mail sent successfully\");", true);
Ive changed the port to : 25, 465,587 but still gives me the same error, when i set to 465 it tells me
Failure to send mail
Ive checked google for some answers but none seems to accomplish or settle the problem. Please help me...
UPDATE: I just tried it again using smtp.gmail.com as the host and port 587. but its still telling me:
Service not available, closing transmission channel. The server response was: Server busy, too many connections
Related
I'm trying to set up a email notification for a asp.net project, but it doesn't seem to work. On localhost it gives me the following error
5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
while on azure it triggers a suspicious login message over and over.
I tried multiple suggestions:
port 25 instead of 587
UseDefaultCredentials true or false
enable and disable SSL
nothing seems to work. The suspecious activity mail is the closest I got so far. Here is my code
var client = new SmtpClient();
client.Host = "smtp.office365.com";
client.UseDefaultCredentials = false;
client.Port = 587;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("Rachelle.XXXX#outlook.com", "password");
client.DeliveryMethod = SmtpDeliveryMethod.Network;
var message = new MailMessage("Rachelle.XXXX#outlook.com", "Rachelle_xxxxx#hotmail.com");
message.Subject = "a ticket has been changed";
message.Body = "Hi there, a ticket has been changed on Cronos. Please check Cronos for more details";
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
try
{
client.Send(message);
return message;
}
When a customer buys an item, the button should send an email to the website owner. Here is the code I currently have:
SmtpClient smtpClient = new SmtpClient("smtpout.europe.secureserver.net", 80);
smtpClient.Credentials = new System.Net.NetworkCredential("info#furkantellioglu.com ", "Password");
smtpClient.UseDefaultCredentials = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
MailMessage mail = new MailMessage();
mail.Body = "Bekleyen Siparişleriniz Bulunmakta Lütfen Kontrol Ediniz.";
mail.Subject = "Dermabon Web Satış";
mail.IsBodyHtml = true;
mail.From = new MailAddress("info#furkantellioglu.com", "Sipariş");
mail.To.Add(new MailAddress("info#furkantellioglu.com"));
mail.CC.Add(new MailAddress("f.tellioglu#gmail.com"));
smtpClient.Send(mail);
But when I run it I get this error:
An exception of type 'System.Net.Mail.SmtpException' occurred in System.dll but was not handled in user code
Additional information: Sunucu güvenli bağlantıları desteklemiyor.
Any ideas on what this means?
please try changing
smtpClient.EnableSsl = true;
to
SmtpServer.EnableSsl = false;
a similar thread has been discussed on this forum which might help you Link
the error message means the server does not support secure connections. Your are using enable ssl but sending to port 80 so there could be a conflict here.
seems like a port error, try using changing
EnableSsl=false; and or UseDefaultCredentials = true; or use port 25
Im working with email sending App.It works perfect in Local System(My system). When i hosted it into server it show me the error like "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required".
Here is My Code:
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential
("Mymail#gmail.com", "Mypwd");
smtp.EnableSsl = true;
smtp.Send(Msg);
Please try to change
smtp.UseDefaultCredentials = false
to
smtp.UseDefaultCredentials = true;
EDIT
Also try to make
smtp.EnableSsl = false;
Note: This is what I have already working mail client on the server
I am trying to send mail through mail server ( available in fatcow).
Username: info#efernssolutions.com
SMTP Server: smtp.hostname.com
SMTP Port: 587
I used the follwing code to send mail ,
if (ModelState.IsValid)
{
MailMessage message = new MailMessage();
try
{
message.To.Add(new MailAddress("kishore.eferns#gmail.com"));
message.From = new MailAddress("info#efernssolutions.com");
message.Subject = "Test mail";
message.Body = "this is the mail sended through my c#.net program";
message.BodyEncoding = System.Text.Encoding.UTF8;
message.SubjectEncoding = System.Text.Encoding.UTF8;
SmtpClient client = new SmtpClient();
client.Port = 587;
client.Host = "smtp.hostname.com";
System.Net.NetworkCredential nc = new System.Net.NetworkCredential("info#efernssolutions.com", "password");// is u are using Gmail
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = nc;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
client.Send(message);
}
catch (Exception ex)
{
;
}
}
When i use gmail server the code works fine and i received mail.
But it is not working with my email server.
I get the error,
the remote certificate is invalid according to the validation procedure
Is there anything left to do to make it work?
Please help,
Thank you
As first check I will suggest to check if your SSL certificate is correctly installed on your server
I want to Run Below code without
NetworkCredential nc = new Net.NetworkCredential("USERNAME", "PASSWORD").
BY using Only Exchange Host (Server Name) And Port
Im Getting Error For this code : Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender
protected void SendEmail(object sender, EventArgs e)
{
SmtpClient smtpClient = new SmtpClient("ExchangeServerName",25);
MailMessage message = new MailMessage();
try
{
MailAddress fromAddress = new MailAddress("bala#OfficeName.com", "From Me");
MailAddress toAddress = new MailAddress("bala#OfficeName.com", "To You");
message.From = fromAddress;
message.To.Add(toAddress);
message.Subject = "Testing!";
message.Body = "This is the body of a sample message";
smtpClient.UseDefaultCredentials = true;
System.Net.NetworkCredential nc = CredentialCache.DefaultNetworkCredentials;
smtpClient.Credentials = (System.Net.ICredentialsByHost)nc.GetCredential("ExchangeServerName", 25, "Basic");
smtpClient.Send(message);
lblText.Text ="Email sent.";
}
catch (Exception ex)
{
lblText.Text = "Coudn't send the message!\n " + ex.Message;
}
}
I have done it. For more details about my code use this link.
Below Code is worked Fine with
Server : Windows Server 2003,Windows Server 2008,Windows Server 2008 R2
IIS : 6.0, 7.0
.Net Frame Wotk : 2.0,3.5,4.0
string sMessage;
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
//you can provide invalid from address. but to address Should be valil
MailAddress fromAddress = new MailAddress("bala#technospine.com", "BALA");
smtpClient.Host = "Exchange Server Name";
smtpClient.Port = 25;
//smtpClient.Port = 587;
smtpClient.UseDefaultCredentials = true;
message.From = fromAddress;
message.To.Add(bala#technospine.com); //Recipent email
message.Subject = _subject;
message.Body = _details;
message.IsBodyHtml = true;
//smtpClient.EnableSsl = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Send(message);
sMessage = "Email sent.";
}
catch (Exception ex)
{
sMessage = "Coudn't send the message!\n " + ex.Message;
}
lblMailStatus.Text = sMessage;
You are attempting to send a mail message using Exchange. In order to do that, the sender (or sending process) must have permissions on the account it is logged in under to send on behalf of the user you are specifying as the sender. This is different from going through Exchange's SMTP mail transfer agent (MTA) in order to have Exchange receive and route an email message. So you are on the right track with knowing you should do this using SMTP, but you are just trying to use the wrong API for accomplishing this. You want to take a look at CDOSYS for sending it through the SMTP MTA without having to do user authentication. Search on System.Web.Mail.MailMessage for more specific examples - there are plenty out there. If the Exchange server does not seem to accept/deliver the SMTP message delivered to it in this fashion, you might simply need to open up its configuration a bit. In that event, the Exchange server is probably configured with tight security on routing of mail received via its SMTP MTA and just needs to have the IP address of the machine(s) you are sending these messages from configured to allow for mail forwarding.
try NetworkCredential nc = new Net.NetworkCredential("USERNAME", "PASSWORD","DOMAIN")