- Home /
How to send a e-mail via smtp
Is there a possibility to send an e-mail via SMTP server using? I found a script on that topic for java, but it doesn't work in unity. That's the example i found:
package com.mkyong.common;
import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage;
public class JavaMailApp1 { public static void main( String[] args ) {
String host = "smtp.gmail.com"; int port = 587; String username = "username"; String password = "password";
Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true");
Session session = Session.getInstance(props);
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("from@no-spam.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("to@no-spam.com"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler,\n\n No spam to my email, please!");
Transport transport = session.getTransport("smtp");
transport.connect(host, port, username, password);
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
Can anyone please help me, i don't know how to get this script working in unity.
thx for answeres :)
Your answer
Follow this Question
Related Questions
Simple Email Script 2 Answers
Setting Scroll View Width GUILayout 1 Answer
Sending a string via email from Unity? 2 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers
How to email highscore through android? 2 Answers