java - Trying to use JavaMail -


So I'm trying to create a server where I can change the sender's email to whatever I want. I have tried to sign up for a free SMTP server, but I'm not sure what I'm allowed to do. If this does not work then can someone take me in SMTP server which allows me to do this?

  Package Mailer 2; Import java.util.Date; Import java.util.Properties; Import javax.mail.Authenticator; Import javax.mail.Message.RecipientType; Import javax.mail.MessagingException; Import javax.mail.Multipart; Import javax.mail.PasswordAuthentication; Import javax.mail.Session; Import javax.mail.Transport; Import javax.mail.internet.AddressException; Import javax.mail.internet.InternetAddress; Import javax.mail.internet.MimeBodyPart; Import javax.mail.internet.MimeMessage; Import javax.mail.internet.MimeMultipart; Public class mailer 2 {public static zero main (string [] args) address exception, messaging upshot {property prop = new property (attribute); Prop.put ("mail.smtp.host", "ssrs.reachmail.net"); Prop.put ("mail.smtp.port", "587"); Session = Session.getDefaultInstance (prop, new Authenticator () {// ignore mail server @Override method protected PasswordAuthentication getPasswordAuthentication (to prove) {New PasswordAuthentication return ( "MCA28 \\ admin", "NotShowingPassword");} }); Session.setDebug (true); MimeMessage Message = New MimeMessage (Session); Message.Set (new InternetAudio ("yo@yo.com")); message. Sender (recipient type.To, "EmailSotense @ gmail.com"); Msg.setSubject ("Air Force Academy"); // Start MimeBodyPart to fill email content MimeBodyPart messagePart = new MimeBodyPart (); MessagePart.setText ("Message Content"); Multipart Multipart = New Mime Multipart (); Multipart.addBodyPart (messagePart); Msg.setContent (Multipurpose); // Email sending process Transport.send (message); }}   

Login here:

Code << code> prop.put ("mail.smtp.auth", "true"); .

Depending on the provider, you may need to request SSL or STARTLS mail submission port too.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -