Reputation: 35
Can I send e-mail without any authentication?
Like in php:
<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Upvotes: 3
Views: 545
Reputation: 587
You can use JavaMail, but this is only 50% related since you have to set up at least 1 Email account at a hoster which you will parse the sender's id and the target adress.
At the start of this class, there's this:
// Hier bitte die ensprechenden Attribute jeweils anpassen
GMX("mail.gmx.net", 25, "[email protected]", "yxcvbnm1", "[email protected]"),
GOOGLEMAIL("smtp.googlemail.com", 25, "login", "passwort", "absender"),
ARCOR("mail.arcor.de", 25, "login", "passwort", "absender"),
WEB("smtp.web.de", 25, "login", "passwort", "absender"),
YAHOO("smtp.mail.yahoo.de", 25, "login", "passwort", "absender"),
// Hier können weitere E-Mail Accounts als ENUM angelegt werden
;
The first one I created some time ago, you can use it for testing if you want. Look out for JavaMail. You will have to use this library unless you want to reinvent everything.
Here's a example program I just took out of their "demo" folder (sorry it's an applet)
HTML : http://pastebin.com/bHkrNNS0
JAVA : http://pastebin.com/88g941SP
DOCS : http://pastebin[dot]com/sgQGRKhJ
One last thing:
If you want the data to be send anonymously (or perhaps hidden=?) i recommend the usage of Java's Serversocket and Socket classes. If you kind of just want to send an id and a quik message I would preferre this as it's faster written and the server itself can handle and save the messages just like an email server would....
Upvotes: 1