How to send mail from Godaddy? - Java Mail

UPDATED: 27 September 2011
Hello folks if you are using Goddady as you hosting site for JSP, Servlet, etc...We need to send mail from our domain to users. I'm giving you the steps how you can send mail using Java from your domain on Godaddy.

Step 1 : Login to your Goddady account
Step 2 : Login to web mail . To login click on Check my web mail.


Step 3 : Now You need your SMTP (Simple Mail Transfer Protocol) URL. Goto Help menu Click on Email Client


That will pop up your domain Incoming and Outgoing server URL


Now you need SMTP server URL : smtpout.asia.secureserver.net (*This is for my domain it may different for your domain)

Now the Code. I'm giving you the sample code. Change it as your domain.

private static final String SMTP_HOST_NAME = "smtpout.asia.secureserver.net"; //smtp URL
private static final int SMTP_HOST_PORT = 465; //port number
private static String SMTP_AUTH_USER = "Username"; //email_id of sender
private static String SMTP_AUTH_PWD = "Password"; //password of sender email_id

try {
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtps");
    props.put("mail.smtps.host", SMTP_HOST_NAME);
    props.put("mail.smtps.auth", "true");

    Session mailSession = Session.getDefaultInstance(props);
    mailSession.setDebug(true);
    Transport transport = mailSession.getTransport();
    MimeMessage message = new MimeMessage(mailSession);

    message.setSubject(Subject);
    message.setContent("Message that you want to send", "text/html");
    Address[] from = InternetAddress.parse("abc@your_domain.com");//Your domain email
    message.addFrom(from);
    message.addRecipient(Message.RecipientType.TO, new InternetAddress("abc@javaquery.com")); //Send email To (Type email ID that you want to send)

    transport.connect(SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_AUTH_USER, SMTP_AUTH_PWD);
    transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
    transport.close();
} catch (Exception e) {
 e.printStackTrace();
}
This is how you can send email from your Godaddy account. You need the API of Javamail Download from here http://www.oracle.com/technetwork/java/index-138643.html. Include it to lib folder.

0 comments :