Πρόσβαση στον διακομιστή SMTP - πώς μπορώ να πιστοποιήσω την αυθεντικότητα του ταχυδρομείου που στέλνω με τον διακομιστή smtp;

If you use JavaMail api provided by Sun then you can get the latest api from Sun Downloads.
JavaMail uses properties to load all configuration to the program.
You must specify:
# The hostname or IP address of your SMTP server
mail.smtp.host=smtp.duke.java.sun.com

# You get lots of debugging information if
# this is turned on. Comment this line to turn
# it off.
mail.debug=true

# The To email address
ttapr2004.to=duke@duke.java.sun.com

# The From email address
ttapr2004.from=duke@j2ee_fanclub.java.su…

You can easily connect without authenticate to the SMTP server. But you may experience that you cannot send email from your java program:
1. Your ip may be blocked by firewall to Access SMTP Server
2. Your SMTP server block senders address, to address and maybe your ip.
3. Your SMTP server requires authentication

If your server requires authentication this igot it from internet
————————————–…
public class SendMailUsingAuthentication {

private static final String SMTP_HOST_NAME = "myserver.smtphost.com";
private static final String SMTP_AUTH_USER = "myusername";
private static final String SMTP_AUTH_PWD = "mypwd";

private static final String emailMsgTxt =
"Online Order Confirmation Message. Also include the Tracking Number.";
private static final String emailSubjectTxt = "Order Confirmation Subject";
private static final String emailFromAddress = "sudhir@javacommerce.com";

// Add List of Email address to who email needs to be sent to
private static final String[] emailList = {
"mark@yahoo.com", "robin@javacommerce.com"};

public static void main(String args[]) throws Exception {
SendMailUsingAuthentication smtpMailSender = new
SendMailUsingAuthentication();
smtpMailSender.postMail(emailList, emailSubjectTxt, emailMsgTxt,
emailFromAddress);
System.out.println("Sucessfully Sent mail to All Users");
}

public void postMail(String recipients[], String subject,
String message, String from) throws MessagingException {
boolean debug = false;

//Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true"),;

Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth);

session.setDebug(debug);

// create a message
Μήνυμα msg = new MimeMessage(session),;

// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);

InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType…. addressTo);

// Setting the Subject and Content Type
msg.setSubject(subject),;
msg.setContent(message, "text/plain");
Transport.send(msg),;
}

/**
* SimpleAuthenticator is used to do simple authentication
* when the SMTP server requires it.
*/
private class SMTPAuthenticator
extends javax.mail.Authenticator {

public PasswordAuthentication getPasswordAuthentication() {
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
return new PasswordAuthentication(username, password),;
}
}
}
————————————–…

Αποποίηση ευθυνών - Οι απόψεις που εκφράζονται σε αυτό το άρθρο παρέχονται από ένα 3ο μέρος και μπορεί να μην ταιριάζουν με εκείνες της ιστοσελίδας μας

Αυτή η εγγραφή δημοσιεύτηκε στο SMTP Questions. Σελιδοδείκτης στο permalink.

Αφήστε μια απάντηση

Η ηλ. διεύθυνση σας δεν δημοσιεύεται. Τα υποχρεωτικά πεδία σημειώνονται με *

Όλοι γνωρίζουν ότι η ύπαρξη ενός αξιόπιστου διακομιστή SMTP είναι το κλειδί για να παραδίδεται σωστά το ηλεκτρονικό σας ταχυδρομείο. Είναι επίσης γνωστό ότι ΚΑΝΕΙΣ δεν προσφέρει πλέον SMTP χωρίς έλεγχο ταυτότητας ή για ανοικτή αναμετάδοση. ΑΛΛΆ ΜΠΟΡΕΊΤΕ ΑΚΌΜΑ ΝΑ ΑΠΟΚΤΉΣΕΤΕ ΈΝΑΝ ΥΨΗΛΉΣ ΠΟΙΌΤΗΤΑΣ ΔΙΑΚΟΜΙΣΤΉ SMTP ΔΩΡΕΆΝ ΓΙΑ ΤΗ ΧΡΉΣΗ ΣΑΣ!

Κάντε κλικ εδώ για τον ΔΩΡΕΑΝ SMTP SERVER σας