Steam Steam - 5 months ago 5
Java Question

Sending mails from an SMTP server

I know that to send an e-mail from an SMTP server, one needs a server address, password and username/default credentials. But, does SMTP also have a password to access the server itself ? Is there a username as well ?


All you need is

  • hostname:
  • port: 25 or 465 (depending on if SSL)
  • username: myuser
  • password: mypassword

You do not need a password to the "server itself" or anything like that.

Depending on the server config, the email you send "from" may or may not need to be a valid email address on that server.

EDIT: basic C# implementation

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.Subject = "This is the Subject line";
message.From = new System.Net.Mail.MailAddress("",25);
message.Body = "This is the message body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");
// if you need user/pass login
client.Credentials = new NetworkCredential("username","password");