您好我正在尝试通过我的$max = "SELECT Id FROM trialtabel2 order by id desc limit 1";
$max1 = mysqli_query($dblink, $max);
$result = mysqli_fetch_assoc($max1);
pre($result);
实施电子邮件发送。这就是我的Web Application
java
:
class
当我在上面指定的类中编写import javax.mail.*;
import javax.mail.internet.*;
import java.util.Properties;
import javax.activation.*;
public class SendMail{
public void sendEmail(String fromEmail, String toEmail,String subject, String message) throws MessagingException{
System.setProperty("java.net.preferIPv4Stack" , "true");
Properties props = System.getProperties();
props.put("mail.smtp.auth", "false");
props.put("mail.smtp.starttls.enable", "false");
props.put("mail.smtp.host", "localhost");
props.put("mail.smtp.port", "587");
Session mailSession = Session.getInstance(props,null);
mailSession.setDebug(true);
Message mailMessage = new MimeMessage(mailSession);
mailMessage.setFrom(new InternetAddress(fromEmail));
mailMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(toEmail));
mailMessage.setSubject(subject);
mailMessage.setText(message+"This E-Mail was sent to you");
Transport.send(mailMessage);
}
}
方法并将其作为main
或通过任何其他具有java application
方法的类运行时,上述代码绝对正常。但是当我运行main
并将java.net.SocketException: Network is unreachable: connect] with root cause
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
方法调用到没有web application
方法的类时,它会显示sendMail
。我该如何解决呢。任何帮助非常感谢。
任何人都可以提供有关此错误main
的任何更新。即使我进行密码验证Exception in thread "main" javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: 530 5.7.0 Authentication required
,为什么要求它。我解决了所有以前的错误并获得了这样的新错误。任何帮助非常感谢。