Reputation: 49329
I am writing a class to connect to a SMTP server over SSL and send a mail. The smtp server i am using (yahoo) requires authentication. Can someone tell me how the authentication takes place as to which commands i should use to send my user credentials?
Note: I know about the JavaMail API. I just want a simple class to send mail without outside libraries.
Upvotes: 0
Views: 858
Reputation: 2407
You can do it by following in c#
class smtp
{
SmtpClient client;
MailMessage mm;
void send()
{
mm.send();
}
void smtp_configure()
{
client.Credentials = new NetworkCredential(username, password);
client.Port = smtp_port;
client.Host = smtp_host;
client.EnableSsl = true;
}
message_configure()
{
mm = new MailMessage(From, To);
mm.Body = MgsText;
mm.BodyEncoding = Encoding.UTF8;
mm.Subject = Subject;
}
Main()
{
smtp_configure();
message_configure();
send();
}
}
Upvotes: 0
Reputation: 26149
Internet RFC 821 covers the basics of the SMTP protocol, and RFC 2554 covers the authentication extensions. You'll need many of them to get a functional SMTP client up.
But, really, it's much simpler to just use JavaMail (unless this is a homework assignment, in which case, I'm guessing that would be cheating.)
Upvotes: 3