hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gerdes, Tom" <TGer...@OldRepublicTitle.com>
Subject RE: Is it possible to send and email using HTTPCLIENT?
Date Wed, 20 Oct 2004 14:18:59 GMT
Thanks, for the example!

Question though about it...  In the main you use the "send" class.  Is
this supposed to be "SendApp", or am I missing something about the code?


-----Original Message-----
From: IndianAtTech [mailto:IndianAtTech@gmail.com] 
Sent: Wednesday, October 20, 2004 1:11 AM
To: Commons HttpClient Project
Subject: Re: Is it possible to send and email using HTTPCLIENT?

HttpClient is specific to Http/hhtps protocols. You can't send messages
to email server using Http client.

You  need to have local SMTP mail server/SMTP mail server provided by
your ISP  configured to your java application for sending the messages
to external server.

This code example might help you

from:  http://www.javaalmanac.com/egs/javax.mail/SendApp.html?l=new


import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    
    public class SendApp {
        public static void send(String smtpHost, int smtpPort,
                                String from, String to,
                                String subject, String content)
                throws AddressException, MessagingException {
            // Create a mail session
            java.util.Properties props = new java.util.Properties();
            props.put("mail.smtp.host", smtpHost);
            props.put("mail.smtp.port", ""+smtpPort);
            Session session = Session.getDefaultInstance(props, null);
    
            // Construct the message
            Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(from));
            msg.setRecipient(Message.RecipientType.TO, new
InternetAddress(to));
            msg.setSubject(subject);
            msg.setText(content);
    
            // Send the message
            Transport.send(msg);
        }
    
        public static void main(String[] args) throws Exception {
            // Send a test message
            send("hostname", 25, "joe@smith.com", "sue@smith.com",
                 "re: dinner", "How about at 7?");
        }
    }








On Tue, 19 Oct 2004 14:10:34 -0500, Gerdes, Tom
<tgerdes@oldrepublictitle.com> wrote:
> Can I just send a multipart post to an email server with attached 
> files using Httpclient?  Would this work for an email?  If so, does 
> anyone have an example of doing this?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail:
commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail:
commons-httpclient-dev-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message