+1 vote

i want sending mail using smtp using specific port.
now, i can specifate the port.

by

1 Answer

0 votes
 
Best answer

Both Connect and ConnectSSL methods have overloads that take port as one of the parameters:

IMail email = Mail.Text("Hello")
    .From("from@example.com")
    .To("to@example.com")
    .Subject("Subject")
    .AddAttachment(@"c:\tmp.doc").SetFileName("document.doc")
    .Create();

using(Smtp smtp = new Smtp());
{
    smtp.Connect("server", 25); // or smtp.ConnectSSL("server", 465);

    smtp.UseBestLogin("user", "password");

    smtp.SendMessage(email);                      

    smtp.Close();    
}
by (297k points)
...