Hallo,
hab ein Programm, das mir Emails zusenden soll. Doch als Fehlermeldung kommt immer:
"Need to authenticate via SMTP-AUTH-Login {mp033}"
Hab auch schon gegoogelt, aber da finde ich nichts, was ich verstehe Wäre cool, wenn jemand den Code gleich berichtigen könnte. Danke!
Hier der Code:
------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
hab ein Programm, das mir Emails zusenden soll. Doch als Fehlermeldung kommt immer:
"Need to authenticate via SMTP-AUTH-Login {mp033}"
Hab auch schon gegoogelt, aber da finde ich nichts, was ich verstehe Wäre cool, wenn jemand den Code gleich berichtigen könnte. Danke!
Hier der Code:
------------------------------------------------------------
Code:
public static void mailLog(String subject, String filePathname, Prefs prefs)
{
String hostName;
String mailHost = prefs.getMailhostAddress();
String mailToAddress = "<" + prefs.getMailToAddress() + ">";
String mailFromAddress = "<" + prefs.getMailFromAddress() + ">";
debugFlag = ETWS.getDebugMode();
// check mail host (mail server)
if (mailHost.length() == 0)
{
Logger.log("Mailer: Ungültiger Mailserver");
return;
}
// get the host name (Tini's name)
try
{
hostName = InetAddress.getLocalHost().getHostName();
//hostName = "javaWeatherServer";
}
catch (UnknownHostException e)
{
Logger.log("Warning: You must use 'hostname' to sent a host name");
hostName = "tini";
}
if (debugFlag)
{
System.out.println("Maile Logdatei");
System.out.println("An : " + mailToAddress);
System.out.println("Von : " + mailFromAddress);
System.out.println("Mailserver : " + mailHost);
System.out.println("Dateiname : " + filePathname);
System.out.println("Sende von: " + hostName);
}
try
{
// open a connection to the mail host
Socket s = new Socket(mailHost, 25);
if (s != null)
{
// set up bufered readers & writers to the socket
out = new PrintStream(s.getOutputStream());
in = new BufferedReader(new InputStreamReader(s.getInputStream()));
// send a leading null to start transaction
send(null);
send("HELO " + hostName);
if (readResponse())
{
send("MAIL FROM: " + mailFromAddress);
if (readResponse())
{
send("RCPT TO: " + mailToAddress);
if (readResponse())
{
send("DATA");
if (readResponse())
{
send("SUBJECT: " + hostName + " " + filePathname);
send("TO: " + mailToAddress);
send("FROM: " + mailFromAddress);
send("DATE: " + new Date());
send("");
sendFile(filePathname);
send("");
send(".");
readResponse();
}
}
}
send("QUIT");
------------------------------------------------------------------------------------------------------------------------