1

I have bought a cPanel host and the SMTP server information is:

info

This is my code:

string smtpAddress = "mandane.hostcream.com";
int portNumber = 465;
bool enableSSL = true;
string emailFrom = "[email protected]";
string password = Authenitication.PassWord;
string emailTo = To.Text;
string subject = Subject.Text;
string body = Body.Text;

using (MailMessage mail = new MailMessage())
{
    mail.From = new MailAddress(emailFrom);
    mail.To.Add(emailTo);
    mail.Subject = subject;
    mail.Body = body;
    mail.IsBodyHtml = true;

    using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
    {
        smtp.Credentials = new NetworkCredential(emailFrom, password);
        smtp.EnableSsl = enableSSL;
        smtp.Send(mail);
    }
}

When I run my code and click on the send button after 1 or 2 minutes this appears:

Additional information: Failure sending mail.

What am I doing wrong?

14
  • have you double checked the email and password are right? Also do you have any attachments?
    – Prix
    Commented Aug 28, 2014 at 9:55
  • yes the email and password is correct ... Commented Aug 28, 2014 at 9:59
  • no i have not any attachments...but user and passwords i am sure that they are correct.. Commented Aug 28, 2014 at 9:59
  • Well the error you've updated is some malformed information within the message and/or wrong user/pass
    – Prix
    Commented Aug 28, 2014 at 10:01
  • The error message is from STMP server?
    – Jumpei
    Commented Aug 28, 2014 at 10:01

2 Answers 2

4

I think you missed something, try this:

SmtpClient smtpClient = new SmtpClient();
NetworkCredential smtpCredentials = new NetworkCredential("email from","password");

MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("email from");
MailAddress toAddress = new MailAddress("email to");

smtpClient.Host = "smpt host address";
smtpClient.Port = your_port;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = smtpCredentials;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Timeout = 20000;

message.From = fromAddress;
message.To.Add(toAddress);
message.IsBodyHtml = false;
message.Subject = "example";
message.Body = "example";

smtpClient.Send(message);
1
  • the method is good and work for me in my apps...so I do not know what you are doing wrong...
    – Sowiarz
    Commented Aug 28, 2014 at 10:12
0

It seems that you cannot reach Yahoo address on port 465, please check if this address reachable first because it appears to be a network issue.

7
  • Its not Yahoo ! its my cPanel hosting ! first i have set enable SSL to false but i changed it true and now this appears : Additional information: Failure sending mail. Commented Aug 28, 2014 at 9:51
  • Can you reach the server IP/address ? you can use telnet to test the connection first.
    – G.Nader
    Commented Aug 28, 2014 at 9:55
  • i have ping to "mandane.hostcream.com" and its all right...but telnet i didn't test ... what command should i run ? Commented Aug 28, 2014 at 9:58
  • One easy way to test this is to telnet to mandane.hostcream.com on port 465 and see if it times out. You can use Putty or the built in telnet-client in windows, if you have it installed.
    – G.Nader
    Commented Aug 28, 2014 at 10:00
  • yes i have add telnet client feature in windows features ... but i forgot that how to use telnet commands... Commented Aug 28, 2014 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.