Here is my yahoo smtp mail sender :
Test_Yahoo_Mail.aspx.cs File :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Bitcoin_Doubler
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Send_Email(
"display_name",
"from_mail",
"to_mail",
"subject",
"html_body",
"sender_yahoo_email",
"sender_yahoo_password"
);
}
private void Send_Email(string display_namee, string from, string to, string subject, string html_body, string sender_email, string sender_password)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress(from, display_namee, Encoding.UTF8);
mail.To.Add(to);
mail.SubjectEncoding = Encoding.UTF8;
mail.Subject = subject;
mail.IsBodyHtml = true;
mail.BodyEncoding = Encoding.UTF8;
mail.Body = html_body;
mail.Priority = MailPriority.High;
SmtpClient smtp = new SmtpClient();
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(sender_email, sender_password);
smtp.Host = "plus.smtp.mail.yahoo.com";
smtp.Port = 587;
smtp.Timeout = 120000;
smtp.EnableSsl = true;
//smtp.SendCompleted += new SendCompletedEventHandler(smtp_SendCompleted);
smtp.SendCompleted += (s, e) =>
{
if (e.Cancelled)
{
Console.Write("sending email was canceled");
}
if (e.Error != null)
{
Console.Write("sending email was failed -> Error : " + e.Error.ToString());
}
else
{
Console.Write("email was sent successfully");
}
mail.Dispose();
};
try
{
smtp.SendAsync(mail, null);
}
catch (System.Net.Mail.SmtpException exp)
{
Console.Write("sending email was failed, SmtpException -> Error : " + exp.ToString());
mail.Dispose();
}
}
}
}
But in this line i got error :
Console.Write("sending email was failed, SmtpException -> Error : " + exp.ToString());
And here is the error :
"Failure sending mail."
I tried
smtp.Send(mail);
instead of smtp.SendAsync(mail, null);
= Same errorI also tried this site codes = Same error
Mean tried
smtp.mail.yahoo.com
instead of plus.smtp.mail.yahoo.com
= Same errorI also tried
25
, 465
, 587
ports.For all of them = Same error
Would you please tell me what is a problem & fix my mail method or give me a new one with html body.