Re: DEBUG SMTP RCVD: 354 Enter mail, end with "." on a line by itself

Tech-Archive recommends: Speed Up your PC by fixing your registry



here is my source code-----------------

/*
Some SMTP servers require a username and password authentication before
you
can use their Server for Sending mail. This is most common with couple
of ISP's who provide SMTP Address to Send Mail.

This Program gives any example on how to do SMTP Authentication
(User and Password verification)

This is a free source code and is provided as it is without any
warranties and
it can be used in any your code for free.

*/

import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;

/*
To use this program, change values for the following three constants,

SMTP_HOST_NAME -- Has your SMTP Host Name
SMTP_AUTH_USER -- Has your SMTP Authentication UserName
SMTP_AUTH_PWD -- Has your SMTP Authentication Password

Next change values for fields

emailMsgTxt -- Message Text for the Email
emailSubjectTxt -- Subject for email
emailFromAddress -- Email Address whose name will appears as "from"
address

Next change value for "emailList".
This String array has List of all Email Addresses to Email Email
needs to be sent to.


Next to run the program, execute it as follows,

SendMailUsingAuthentication authProg = new
SendMailUsingAuthentication();

*/

public class SendMailUsingAuthentication
{

private static final String SMTP_HOST_NAME = "10.220.43.82";
private static final String SMTP_AUTH_USER = "bea";
private static final String SMTP_AUTH_PWD = "bea";

private static final String emailMsgTxt = "\nmanish \r\n.\r\n.";
private static final String emailSubjectTxt = "Order Confirmation
Subject1";
private static final String emailFromAddress =
"tushar.mittal@xxxxxx";

// Add List of Email address to who email needs to be sent to
private static final String[] emailList = {"kapil.varshney@xxxxxx"};

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

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

//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();
//Authenticator auth=new SMTPAuthenticator( "bea", "bea" );

Session session = Session.getDefaultInstance(props, auth);

session.setDebug(debug);

// create a message
Message msg = new MimeMessage(session);
System.out.println("got 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.TO, addressTo);


// Setting the Subject and Content Type
System.out.println("before setting subject");
msg.setSubject(subject);
System.out.println("before setting contect");
msg.setContent(message, "text/plain");
System.out.println("after setting contect");
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);
}
}

}

.



Relevant Pages

  • .SMTPSendFailedException: 553 Sorry, over your daily relay limit.
    ... I am using javamail to send mails through SMTP. ... I am using authentication at server ... private static final String emailMsgTxt = "Online Order ... SimpleAuthenticator is used to do simple authentication ...
    (comp.lang.java.programmer)
  • sendmail client side smtp authentication problem
    ... sendmail client side smtp authentication problem ... made and installed cf, restarted sendmail, ... # Resolve map (to check if a host exists in check_mail) ...
    (freebsd-questions)
  • ASP.NET Forms Authentication Best Practices
    ... ASP.NET Forms Authentication Best Practices ... What happens if your user database is compromised? ... Listing One, where you want to use login.aspx to log users in. ... string FirstName ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Outlook could not logon to the outgoing mail server - Exchange server
    ... In the Exchange System Manager go to the SMTP Protocol --> Default ... Based on my experience,I think The root cause is your smtp server have been ... configured to require authentication,but your outlook 2003 and outlook ... express authentication are not being configured on the client. ...
    (microsoft.public.windows.server.sbs)
  • Re: Exchange SMTP Hole?
    ... Maybe authenticated SMTP using some weak credentials? ... A worrisome new kind of attack is making the rounds on the ... 2000 Server have relaying turned off by default!" ... authentication on any SMTP virtual server that faces the Internet. ...
    (Focus-Microsoft)