Sending email using java
Im using this code to do this, but i have a feeling that I need to close os and is is that the case? do i need to close anything else?
thanks
tzaf
//code used to send email starts here
String m_sHostName="localhost";
int m_iPort=25;
try
// Open port to server
smtpSocket = new Socket(m_sHostName, m_iPort);
os = new DataOutputStream(smtpSocket.getOutputStream());
is = new DataInputStream(smtpSocket.getInputStream());
if(smtpSocket != null && os != null && is != null)
// Connection was made. Socket is ready for use.
System.out.println("Connection was made. Socket is ready for use.");
try
// The email address that the server
// you are using know user as.
os.writeBytes("MAIL From: <[email protected]>\r\n");
// Who the email is going to.
os.writeBytes("RCPT To: <[email protected]>\r\n");
//send a CC to:
os.writeBytes("RCPT Cc: <[email protected]>\r\n");
// add the message and the
// header of the email to be sent out.
os.writeBytes("DATA\r\n");
os.writeBytes("X-Mailer: Via Java\r\n");
os.writeBytes("From: "+WebUsername2+"<[email protected]>\r\n");
os.writeBytes("To: Marie <[email protected]>\r\n");
//Again if you want to send a CC then add this.
os.writeBytes("Cc: ProfCuthbert <[email protected]>\r\n");
String sMessage = "ELECTRONIC ENGINEERING EXAM COLLATION SYSTEM EMAIL\n\nThe results for the following course have been submitted by the following member of staff\n\nCOURSE: "+WebCourse2+"\n\nSUBMITTED BY: "+WebUsername2+" \n\nPLEASE LOCK COURSE NOW IN ORDER TO PREVENT ANY FURTHER SUBMISSIONS TO BE MADE BY USERS.";
os.writeBytes("Subject: A SUBMISSION HAS BEEN MADE FOR COURSE "+WebCourse2+"\r\n");
os.writeBytes(sMessage + "\r\n");
os.writeBytes("\r\n.\r\n");
os.writeBytes("QUIT\r\n");
// Now send the email off and check the server reply.
// Once an OK is reached you are complete.
String responseline;
//for testing purposes
//out.println(responseline = is.readLine());
while((responseline = is.readLine())!=null)
//for testing purposes
//out.println("responseline= "+responseline+"<br>");
//out.println("responseline.indexOf(Ok)= "+responseline.indexOf("Ok"));
if(responseline.indexOf("Ok") != -1)
break;
if(responseline.indexOf("Ok") == -1)
confirm=1;
if (confirm==1)
out.println("<br>the marks have been submitted thank you");
catch(Exception e)
{ System.out.println("Cannot send email as an error occurred.");
out.println("Cannot send email as an error occurred.");
catch(Exception e)
{ System.out.println("Host " + m_sHostName + "unknown"); }
//code used to send email ends here
any thoughts?
thanks
tzaf
Similar Messages
-
How to send emails using java code
Hi,
can any give me some sample code for sending emails using java languageJavaMail quick start
jGuru: Fundamentals of the JavaMail API -
I am using the following code to send an email from my java servlet but the problem is, when it is on its own it works fine but as soon as I combine it with some code to submit data into a postgres database it sometimes does not perform could it be because im missing some close statements??
//grades to submit grades starts here
String [] paramValues = req.getParameterValues("Mark");
for(int i=0; i<paramValues.length;i++)
String [] paramValues2 = req.getParameterValues("StudentExamNumber");
String Mark = paramValues;
String ExamNo = paramValues2[i];
//testing purposes
out.println("<tr><td>"+ExamNo+"</td>");
out.println("<td>"+Mark+"</td>");
try
st = conn.createStatement();
query = "SELECT StudentNo FROM STUDENTS"+WebCourse2+ " where ExamNo='"+ExamNo+"'";
rs = st.executeQuery(query);
if(rs !=null)
while(rs.next())
String StudentNo=rs.getString("StudentNo");
//testing purposes
//out.println("<td>"+StudentNo+"</td></tr>");
here
st4 = conn.createStatement();
query4 = "select MAX(entryno) from STUDENTRESULTSFORCOURSE"+WebCourse2+" WHERE STUDENTNO='"+StudentNo+"'";
rs4 = st4.executeQuery(query4);
if(rs4 !=null)
while(rs4.next())
EntryNo = rs4.getInt(1);
}//end rs4 while
rs4.close();
}//end rs4 if
out.println("<tr><td>EntryNo= "+EntryNo+"</td>");
EntryNo = EntryNo + 1;
out.println("<td>NewEntryNo= "+EntryNo+"</td></tr>");
//Submitting grades to database/
st3 = conn.createStatement();
insert = "insert into STUDENTRESULTSFORCOURSE"+WebCourse2+" (StudentNo, CourseCode, AttemptNo, ExamMark, EntryNo, EnteredBy) values ('"+StudentNo+"', '"+WebCourse2+"', 1,'"+Mark+"',"+EntryNo+",'"+WebUsername2+"')";
st3.executeUpdate(insert);
}//end rs while
rs.close();
}//end rs if
}//end try
catch (SQLException e)
System.out.println("Error: "+e.getMessage());
}//end for loop
//code to submit grades ends here
//code used to send email starts here
String m_sHostName="localhost";
int m_iPort=25;
try
// Open port to server
smtpSocket = new Socket(m_sHostName, m_iPort);
os = new DataOutputStream(smtpSocket.getOutputStream());
is = new DataInputStream(smtpSocket.getInputStream());
if(smtpSocket != null && os != null && is != null)
// Connection was made. Socket is ready for use.
System.out.println("Connection was made. Socket is ready for use.");
try
// The email address that the server
// you are using know user as.
os.writeBytes("MAIL From: <[email protected]>\r\n");
// Who the email is going to.
os.writeBytes("RCPT To: <[email protected]>\r\n");
//send a CC to:
os.writeBytes("RCPT Cc: <[email protected]>\r\n");
// add the message and the
// header of the email to be sent out.
os.writeBytes("DATA\r\n");
os.writeBytes("X-Mailer: Via Java\r\n");
os.writeBytes("From: "+WebUsername2+"<[email protected]>\r\n");
os.writeBytes("To: Marie <[email protected]>\r\n");
//Again if you want to send a CC then add this.
os.writeBytes("Cc: ProfCuthbert <[email protected]>\r\n");
String sMessage = "ELECTRONIC ENGINEERING EXAM COLLATION SYSTEM EMAIL\n\nThe results for the following course have been submitted by the following member of staff\n\nCOURSE: "+WebCourse2+"\n\nSUBMITTED BY: "+WebUsername2+" \n\nPLEASE LOCK COURSE NOW IN ORDER TO PREVENT ANY FURTHER SUBMISSIONS TO BE MADE BY USERS.";
os.writeBytes("Subject: A SUBMISSION HAS BEEN MADE FOR COURSE "+WebCourse2+"\r\n");
os.writeBytes(sMessage + "\r\n");
os.writeBytes("\r\n.\r\n");
os.writeBytes("QUIT\r\n");
// Now send the email off and check the server reply.
// Once an OK is reached you are complete.
String responseline;
//for testing purposes
//out.println(responseline = is.readLine());
while((responseline = is.readLine())!=null)
//for testing purposes
//out.println("responseline= "+responseline+"<br>");
//out.println("responseline.indexOf(Ok)= "+responseline.indexOf("Ok"));
if(responseline.indexOf("Ok") != -1)
break;
if(responseline.indexOf("Ok") == -1)
confirm=1;
if (confirm==1)
out.println("<br>the marks have been submitted thank you");
catch(Exception e)
{ System.out.println("Cannot send email as an error occurred.");
out.println("Cannot send email as an error occurred.");
catch(Exception e)
{ System.out.println("Host " + m_sHostName + "unknown"); }
Does anyone know what the problem is??
thanks
tzafi close them later in the program. Ive made sure they are all closed I have a feeling that it could be coming from here....
//code used to send email starts here
String m_sHostName="localhost";
int m_iPort=25;
try
// Open port to server
smtpSocket = new Socket(m_sHostName, m_iPort);
os = new DataOutputStream(smtpSocket.getOutputStream());
is = new DataInputStream(smtpSocket.getInputStream());
if(smtpSocket != null && os != null && is != null)
// Connection was made. Socket is ready for use.
System.out.println("Connection was made. Socket is ready for use.");
try
// The email address that the server
// you are using know user as.
os.writeBytes("MAIL From: <email address>\r\n");
// Who the email is going to.
os.writeBytes("RCPT To: <email address>\r\n");
//send a CC to:
os.writeBytes("RCPT Cc: <email address>\r\n");
// add the message and the
// header of the email to be sent out.
os.writeBytes("DATA\r\n");
os.writeBytes("X-Mailer: Via Java\r\n");
os.writeBytes("From: "+WebUsername2+"<email address>\r\n");
os.writeBytes("To: hello<email address>\r\n");
//Again if you want to send a CC then add this.
os.writeBytes("Cc: hello <email address>\r\n");
String sMessage = "ELECTRONIC ENGINEERING EXAM COLLATION SYSTEM EMAIL\n\nThe results for the following course have been submitted by the following member of staff\n\nCOURSE: "+WebCourse2+"\n\nSUBMITTED BY: "+WebUsername2+" \n\nPLEASE LOCK COURSE NOW IN ORDER TO PREVENT ANY FURTHER SUBMISSIONS TO BE MADE BY USERS.";
os.writeBytes("Subject: A SUBMISSION HAS BEEN MADE FOR COURSE "+WebCourse2+"\r\n");
os.writeBytes(sMessage + "\r\n");
os.writeBytes("\r\n.\r\n");
os.writeBytes("QUIT\r\n");
// Now send the email off and check the server reply.
// Once an OK is reached you are complete.
String responseline;
//for testing purposes
//out.println(responseline = is.readLine());
while((responseline = is.readLine())!=null)
//for testing purposes
//out.println("responseline= "+responseline+"<br>");
//out.println("responseline.indexOf(Ok)= "+responseline.indexOf("Ok"));
if(responseline.indexOf("Ok") != -1)
break;
if(responseline.indexOf("Ok") == -1)
confirm=1;
if (confirm==1)
out.println("<br>the marks have been submitted thank you");
catch(Exception e)
{ System.out.println("Cannot send email as an error occurred.");
out.println("Cannot send email as an error occurred.");
catch(Exception e)
{ System.out.println("Host " + m_sHostName + "unknown"); }
//code used to send email ends here
do i need to close is and os?
thanks
tzaf -
I am not able to send email using JAVA API to outer email
If I am trying to send email from my company account to yahoo I am getting following errors:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
for [email protected]
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
at javax.mail.Transport.send0(Transport.java:169)
at javax.mail.Transport.send(Transport.java:98)
at MailSend.main(MailSend.java:116)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to rel
ay for [email protected]
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
... 4 more
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for mkba
[email protected]
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
at javax.mail.Transport.send0(Transport.java:169)
at javax.mail.Transport.send(Transport.java:98)
at MailSend.main(MailSend.java:116)
Please let me know the reason for the same.Unable to relay - This happened because your Company network don't permit relay. Do talk to the network administrator and check with way safe you can send.
I got the same problem, now im using through gmail. -
Can I send email using Java from my localhost(Tomcat) with Internet connect
Hi friends,
Please tell me can I send email from my localhost (Tomcat) using Java when my computer is connected to Internet?
I don't have any SMTP username or password or the like, as I found in some codes available in net.
Please suggest and any simple code if possible.
Please don't send me the link of JavaMail API to read.
---SujoyThank you for the link. Though I have not tested the provided code, I will test it.
--Sujoy -
May i know how to send the email by using java?
heres my final i did for java 1 last year (it was a simple email sending program:
//java FINAL!
import javax.swing.*;
import java.net.URL;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class EmailProg extends JPanel implements ActionListener {
protected JTextArea textArea;
protected String newline = "\n";
static final private String composemail = "compose";
static final private String sendmail = "send";
static final private String about = "about";
static final private String submit = "submit";
static final private String exit = "exit";
JLabel lSubmit = new JLabel("Submit");
JButton subbutton = new JButton();
JTextArea emailfrom = new JTextArea(1,1);
JTextArea emailto = new JTextArea(1, 1);
JTextArea emailsubject = new JTextArea(1, 1);
JTextArea emailmessage = new JTextArea(25, 1);
//------BAG LAYOUT
JLabel lFrom = new JLabel("From:");
JTextField cFrom = new JTextField(32);
JLabel lTo = new JLabel("To:");
JTextField cTo = new JTextField(32);
JFrame frame2 = new JFrame("Compose New");
JLabel lSubject = new JLabel("Subject");
JTextField cSubject = new JTextField(32);
JLabel lMessage = new JLabel("Body");
JTextArea cMessage = new JTextArea(5,32);
//====================================
public EmailProg() {
super(new BorderLayout());
//Create the toolbar.
JToolBar toolBar = new JToolBar();
addButtons(toolBar);
//Create the text area used for output. Request
//enough space for 5 rows and 30 columns.
textArea = new JTextArea(5, 30);
textArea.setEditable(false);
textArea.setText("Welcome to Jeff's email program! With this program you can compose and send emails. I hope I get a good grade on thise, and marine world finds a good use for it :-D:-D (implements really just testing the scroller!!!)");
JScrollPane scrollPane = new JScrollPane(textArea);
//Lay out the main panel.
setPreferredSize(new Dimension(450, 110));
add(toolBar, BorderLayout.NORTH);
add(scrollPane, BorderLayout.CENTER);
//==================================
protected void addButtons(JToolBar toolBar) {
JButton button = null;
//first button
button = makeNavigationButton("/toolbarButtonGraphics/general/ComposeMail24.gif", composemail ,"Compose new Email", "compose new");
toolBar.add(button);
//second button
button = makeNavigationButton("toolbarButtonGraphics/general/SendMail24.gif", sendmail,"Send The Mail","send");
toolBar.add(button);
//third button
button = makeNavigationButton("toolbarButtonGraphics/general/About24.gif", about,"About","About");
toolBar.add(button);
//exit button
button = makeNavigationButton("toolbarButtonGraphics/general/Stop24.gif", exit, "Exit", "Exit");
toolBar.add(button);
//===================================
protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
//Look for the image.
String imgLocation = imageName;
URL imageURL = EmailProg.class.getResource(imgLocation);
//Create and initialize the button.
JButton button = new JButton();
button.setActionCommand(actionCommand);
button.setToolTipText(toolTipText);
button.addActionListener(this);
if (imageURL != null) { //image found
button.setIcon(new ImageIcon(imageURL));
} else { //no image found
button.setText(altText);
System.err.println("Resource not found: "+ imgLocation);
return button;
//=============================
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
String description = null;
// Handle each button.
if (exit.equals(cmd)){
textArea.setText("");
description = "EXITING";
System.exit(0);
if (composemail.equals(cmd)) { //first button clicked
textArea.setText("");
description = "Write new mail.";
composeWindow();
} else if (sendmail.equals(cmd)) { // second button clicked
textArea.setText("");
description = "This button does'nt do anything yet :x";
} else if (about.equals(cmd)) { // third button clicked
textArea.setText("");
description = "About this program. (See pop-up)";
coolWindow();
else if (submit.equals(cmd))
if (cFrom.getText().equals("")||cTo.getText().equals("")||cSubject.getText().equals("")||cMessage.getText().equals(""))
textArea.setText("One or more of the fields was not filled in.");
else{
try {
String smtpServer="serverhere";
String to=cTo.getText();
String from=cFrom.getText();
String subject=cSubject.getText();
String body=cMessage.getText();
send(smtpServer, to, from, subject, body);
textArea.setText("");
description = "Mail Sent.";
JOptionPane.showMessageDialog(null, "Message Sent.");
catch (Exception ex)
System.out.println("Usage: java com.lotontech.mail.SimpleSender"
+" smtpServer toAddress fromAddress subjectText bodyText");
//CLOSE THE FRAME2 WINDOW IIIIIIIIFFFFFFF SENDING IS SUCCESSFUL!!
}//end of else during send
}//end of if of submit
displayResult(description);
//============================
protected void displayResult(String actionDescription) {
textArea.append(actionDescription + newline);
//=============================
public void coolWindow() {
JFrame frame = new JFrame("About");
JTextArea filecontents = new JTextArea();
filecontents.setText("Use the tool bar to compose\n compose new emails, in which you can\n send to anyone on the\n srvhs email server. \n Fill in all the blanks before pressing send. If you dont\n you will receive an error! \n For more information about this program click on the\n information button.");
frame.getContentPane().add(filecontents, BorderLayout.CENTER);
frame.pack();
frame.setResizable(false);
frame.setSize(300,200);
frame.setVisible(true);
//===============================
public void composeWindow() {
frame2.getContentPane().setLayout(new GridBagLayout());
frame2.setResizable(false);
frame2.setSize(600,500);
frame2.setVisible(true);
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(5, 10, 5, 10);
cMessage.setLineWrap(true);
subbutton = makeNavigationButton("toolbarButtonGraphics/general/SendMail24.gif", submit,"submit","submit");
addRow(gbc, lFrom, cFrom);
addRow(gbc, lTo, cTo);
addRow(gbc, lSubject, cSubject);
addRow(gbc, lMessage, cMessage);
addRow(gbc, lSubmit, subbutton);
//===============================
private void addRow(GridBagConstraints gbc, Component left, Component right) {
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridy = GridBagConstraints.RELATIVE;
gbc.gridheight = 1;
gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.EAST;
frame2.getContentPane().add(left, gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.WEST;
frame2.getContentPane().add(right, gbc);
frame2.pack();
//=======================
public static void send(String smtpServer, String to, String from, String subject, String body) {
try {
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpServer);
Session session = Session.getDefaultInstance(props, null);
// -- Create a new message --
Message msg = new MimeMessage(session);
// -- Set the FROM and TO fields --
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
// -- We could include CC recipients too --
// if (cc != null)
// msg.setRecipients(Message.RecipientType.CC
// ,InternetAddress.parse(cc, false));
// -- Set the subject and body text --
msg.setSubject(subject);
msg.setText(body);
// -- Set some other header information --
msg.setHeader("X-Mailer", "LOTONtechEmail");
msg.setSentDate(new Date());
// -- Send the message --
Transport.send(msg);
System.out.println("Message sent OK.");
catch (Exception ex)
ex.printStackTrace();
public static void main(String[] args) {
JFrame frame = new JFrame("EmailProg");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
EmailProg newContentPane = new EmailProg();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setVisible(true);
} -
What do i need to know to send email using Java???
hi there
what do i need to know to build an application that sends email? thank you.It would also help if you knew something about how Internet e-mail works. Such as what an SMTP server does, what relaying is and why it's bad, and so on.
-
Error while sending email using TemplateEmailSender in CSC server
Hi,
We are trying to send email using TemplateEmailSender from CSC server. But it is giving Null Pointer Exception in ProfiledMessageSource like below. The same code is working fine in commerce instance but it is failing in CSC instance. We are using ATG2007.1p3
Any pointers would be helpful.
Below is the error.
Error while sending email
java.lang.NullPointerException
at atg.userprofiling.dms.ProfiledMessageSource.isConfiguredForProfileSubject(ProfiledMessageSource.java:196)
at atg.userprofiling.dms.DPSMessageSource.fireEndSessionMessage(DPSMessageSource.java:864)
at atg.userprofiling.dms.DPSMessageSource.fireEndSessionMessage(DPSMessageSource.java:848)
at atg.userprofiling.SessionEventTrigger.nameContextElementPreUnbound(SessionEventTrigger.java:553)
at atg.nucleus.GenericContext.sendPreUnboundEvent(GenericContext.java:200)
at atg.nucleus.GenericContext.preNotifyRemovedObject(GenericContext.java:528)
at atg.nucleus.GenericContext.removeElement(GenericContext.java:566)
at atg.servlet.SessionNameContext.unbindFromNameContext(SessionNameContext.java:557)
at atg.servlet.SessionNameContext.stopSession(SessionNameContext.java:534)
at atg.servlet.SessionNameContext.decrementWrapperCount(SessionNameContext.java:242)
at atg.servlet.SessionBindingReporter.valueUnbound(SessionBindingReporter.java:206)
at org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1625)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:749)
at org.apache.catalina.session.StandardSession.expire(StandardSession.java:655)
at org.apache.catalina.session.StandardSession.invalidate(StandardSession.java:1100)
at org.apache.catalina.session.StandardSessionFacade.invalidate(StandardSessionFacade.java:150)
at atg.userprofiling.email.TemplateInvoker$TemplateSession.endSession(TemplateInvoker.java:935)
at atg.userprofiling.email.TemplateEmailSender.createMessage(TemplateEmailSender.java:2387)Thanks for the reply.
My issue is fixed now. It is JBOSS configuration issue. Sessions are not maintained properly that's why we are getting NULL profile in the session. Our application has multiple WARs so we fixed it by setting emptySessionPath to TRUE. If emptySessionPath attribute in server.xml is false, then each WAR will have its own jsessionid cookie.
I did not touch ProfiledMessageSource as its required for session triggering. -
How to send attachments using java application and outlook
Hi ,
I created an application in java which is as
on the Conference Tab i can schedule a conference and with the send command on page it map all the scheduled data to outlook(with all conference details) and using outlook send option the mails are send to appropriate user.
but now i want to modify this application such as when i use the send command from my jsp page it should attach the file that is in .vcs or .ics format for auto updation of user calender.
can any one know how to send attachment using java application .Last time I checked, SMS was a service between carriers and doing SMS yourself was really tricky. Some services existed to let you do it but as I recall they wanted non-trivial money.
However, most phone carriers provide an email-to-SMS bridge of some kind.
So the easiest thing is just to send an email.
That's sending from a non-phone to a phone. There's a J2ME library to send/receive SMS from/to a phone.
However, this is from memory, and a little out of date, so I could be entirely wrong. Hope it helps anyway. -
Error in sending mail Using java application using SMTP.
Hi,
I have created a java application of self user registration which also sends email to the user.
I have also added two JAR files ie mail.jar and activation.jar under the PORTAL_INF/lib.
The code works well in other servers but its showing the error-
java.lang.NoSuchMethodError: com.sun.activation.registries.MailcapFile.getMailcapList(Ljava/lang/String;)Ljava/util/Map;
Thanks & Regards,
Amarys.Hi Amarys,
Please check if you have configure the mail server in SAP protal.
Refer to below documents:
[Send email, using SMTP on remote host|Send email, using SMTP on remote host]
[Mailing throw webdynpro for java|Mailing throw webdynpro for java]
Best Regards
Arun Jaiswal -
I'm trying to find out how to send emails with java - without using the java mail api - i've been told there is a way to do it but i cant seem to find it - any help on this would be gratefully recieved as i'm totally stuck! :(
Ok, I expanded on it a little bit. Still probably isnt totally correct.
String localhost="yourdomain.com";
String sendMailHost=�mail.domain.com�;
int portNo=25;
String from="[email protected]";
String to="[email protected]";
String message=�Message Body.�;
Socket s = new Socket(SendMailHost,portNo);
DataInputStream in = new DataInputStream(s.getInputStream() ) ;
PrintStream out = new PrintStream(s.getOutputStream() ) ;
out.println("HELO " + locahost);
out.flush() ;
in.readLine(); //ignore response
out.println("MAIL FROM: " + from);
out.flush() ;
in.readLine(); //ignore response
out.println("RCPT TO: " + to);
out.flush() ;
in.readLine(); //ignore response
out.println("DATA");
out.println(message);
out.println(�.�);
s.close(); -
Attach multiple emails to one master email using Java mail API
Java version: JDK 1.5.0_15
Hi,
I am using Java API to send email using our corporate microsoft exchange server. Everything is working fine, now I have a requirement to attach multiple emails to one master email and send.
Question:
Using JAVA API is it possible to attach multiple emails to one email?
Regards,
ArupThe beginning of this FAQ entry tells you how to attach one message to another message:
http://www.oracle.com/technetwork/java/javamail/faq/index.html#forward -
Loss of sending email using WIFI
As of this morning 8-20-08, after updating to 2.02, I no longer am able to send emails using my own wireless network. Previously this was no problem. Neither Fido or Apple have any idea of what I am talking about. Fido washed their hands as they do not support WIFI. How convenient, they sell the phone and charge for the service but do not support it. Videotron, my ISP, thinks the issue is my wireless router but I can send via gmail so that's out. I resovled the problem by configuring my accounts to use my gmail smtp server as a second option and now the spinning wheel is short lived and messages are sent.
I'm sorry to say that I had fallen for all the hype about Apple but truth is they are but a Microsoft wannabe.
DisinchantedSo here's the wierd thing.
I was having the same problems. Set up SMTP for Videotron when at home using relais.videotron.ca SMTP with no authenticationon port 25 & all was good in the world. However when I went out, bang. Nothing. Couldn't send a mail for love nor money.
Thought aboutit & changed settings to use relais.videotron.ca SMTP, but this time using authentication of vltl** / password credentials with no SSL (Videotron doesn't use SSL) and again everything was fine. Of course, when I got home again, bang. Everything fell over & no more mail sending foe me!
So I figure, when I'm at home I'm on my trusted network at port 25, I don't need authentication and all is good, but when I'm out i'm seen as potential SPAM by port 25 on videotron & get blocked.
Tried using port 587 instead when for both home & mobile but had no luck either.
Then a strange thing happened. I'd resolved to having to set up 2 SMTP servers on my iPhone & switching between the two based on where I was. Pain in the a**, but there's always a trade off for early adopter technology So I set up my primary SMTP to use port 25 with no authentication, and a secondary server to use the same relais.videotron.ca outgoing server, but this time WITH authentication using vltl** \ password credentials.
After a walk to the shop when I'd been on my secondary SMTP server (successfully sending & recieving) I came home & inadvertantly forgot to swith back to my primary SMTP. Recieved a mail & then responded with no problem!
Net result, I now have a permanently switced off primary server & a permanently switched on secondary server which uses relais.videotron.ca details with vltl** \ password authentication credentials active (like I did on my old silver iPhone) & all is good in the world, both at home & out mobile, both for sending & recieving!
Will field test some more tomorrow but it may be a 2.0.2 bug where ther primary server details fcuk up whereas the secondary server details are stable.
So long as it works, who cares!
Jof -
How can I send email using two different email address that both link back to my one exchange account on my Ipad mini?
On my PC I simply have a master return email address and use a POP for the secondary address. Both are through the one exchange account without a problem. I need to be able to do the same on my Ipad.Ah, I should have made that clear. My domain didn't come from google. It was purchased at and is hosted at dreamhost, but I haven't used their email servers in years - I just route everything through gmail. I actually have a bunch of domains (with websites).
Gmail has an option that lets someone with custom domains send (and receive) email through gmail using the custom domain once Google confirms proper ownership of the domain (to prevent spammers and such). Gmail has a setting for "send email as" which allows gmail to be sent using a custom domain as the sender. I'm pretty sure Apple's old mobileme had this feature too, but I didn't use it. -
IPhone cannot send email using Yahoo account. iPhone no envia correo Yahoo.
Hi Everyone,
I just got my iPhone from Movistar Venezuela and I've found I'm unable to send email using my Yahoo account. However, I can receive Yahoo email just fine (paid $20 for Mail Plus subscription), my GMail account can send and receive perfectly, and I can go surfin' Safari with no problems too.
The error message I get is "Cannot send mail: an error occurred while delivering this message". I called Movistar Customer Support and they said everything was fine on their end...
In typical Apple fashion, the error message is so simple I have no idea where the problem is. Does anyone know how can I get more information and how to solve this annoying problem? My Yahoo account is actually my primary account...
Thanks in advance!
Saludos a todos,
Acabo de comprarme un iPhone de Movistar en Venezuela y me encuentro sin poder enviar emails con mi cuenta Yahoo. Sin embargo, si puedo recibir correo Yahoo bien (pague $20 por mi suscripcion a Mail Plus), mi cuenta de GMail si puede enviar y recibir email sin problema y puedo navergar con Safari sin ningun problema.
El mensaje de error que recibo es el siguiente": "No se puede enviar correo: se ha producido un error al enviar el mensaje". Llame a Atencion al Cliente de Movistar y me dijeron que no habia ningun problema con mi linea o con su servicio de datos...
Como tipica cosa Apple, el mensaje de error es tan simple que no tengo NI IDEA de cual es el problema. Alguien mas ha sufrido este problema? Sabe alguien como puedo obtener mas informacion de este error y como solucionarlo? Lamentablemente, mi cuenta Yahoo es mi correo principal...
Gracias de antemano!Creo que resolvi el problema, temporalmente.
1) Borra tu cuenta
2) Vuelvela a crear
3) Ve a Ajustes
4) Ve a Mail Contactos Calendarios
5) Ve a la cuenta problematica
6) Ve a SMTP
7) Anadir nuevo
8)
Nombre servidor: smtp.mail.yahoo.com
Nombre de usuario: no dejar vacio
Contrasena: no dejar vacio
Usar SSL: si
Autenticacion: Contrasena
Puerto del Servidor: 25
Lo consegui de aqui: http://www.emailaddressmanager.com/tips/mail-settings.html
Dime que tal te funciona.
I think I solved the issue, temporarily at least
1) Delete account
2) Create again
3) Go to settings
4) Go to Mail, Contacts, Calendars
5) Open problematic account
6) Go to SMTP
7) Add a new server
8)
Name: smtp.mail.yahoo.com
User name: do not leave blank
Password: do not leave blank
SSL: Yes
Autentication: Password
Port: 25
I got this info from: http://www.emailaddressmanager.com/tips/mail-settings.html
Let me know how this works
Maybe you are looking for
-
Query about Calling One Form from Another using Personalization
Hi All, I have created a Custom form using TEMPLATE.fmb and created functions in Apps and assigned to Responsibility etc and it all works OK. Now, I need to call this Custom form from another seeded(PO form) Via Tools -> Menu. using Forms personaliza
-
Why is apple not providing information on what the problem withe email is and what they are doing to fix, along with a time frame for fixing the problem.
-
How to scale and clip a BitmapImage in Flex 4.5
Here's my problem, I need to scale and clip images into square sized tiles to put into a tile list. Here's how I want it to work: 1. I want all my tiles to be, say, 300px x 300px. 2. For each image, I want to scale the shorter side (either width or h
-
To update BIOS or not to update?
Hello, my current desktop is the Compaq Presario SR5413WM. I've recently begun upgrading some of its components, one of which will be the processor. I'm upgrading from the AMD Athlon 64 LE-1640 Lima 2.7GHz Socket AM2 45W to the AMD Athlon 64 X2 480
-
GRC CUP: Audit Trail Update is incorrect
Hi All, I have noticed while going through one of the requests in Compliant User Provision (CUP) that, the information updated in the "Audit Trail" section of the request is incorrect. Meaning, there were certain roles added to a user. And I got the