Jako mailový program používáme celá firma Lotus Notes. O vlastnostech proxy
nic netuším ale zkusím se zeptat správce.
P.S.
Tomas Hubalek
<[EMAIL PROTECTED] Komu: Java
<[email protected]>
nsemi.com> Kopie:
Odeslal: Předmět: Re: posilani mailu z
javy
konference-bounc
[EMAIL PROTECTED]
06.04.2006 13:54
Odpovězte prosím
uživateli Java
Nejste nahodou za proxy, ktera SMTP predavat neumi? Z nejakeho programu
vam to jde?
Tom
[EMAIL PROTECTED] napsal(a):
> Snažím se odeslat mail z javovského programu, ale zatím bezůspěšně.
Všechny
> pokusy připojit se na seznam končí
> "Unknown SMTP host: smtp.seznam.cz"
>
> Zde (viz dole) jsem naše kód, který by měl snad fungovat , ale
> nefunguje, stejně jako všechny předchozí pokusy. Netušíte prosím někdo
> nějaký háček ?
> Díky. J.N.
>
>
>
> http://forum.java.sun.com/thread.jspa?threadID=615715&tstart=0
>
>
>
>
-----------------------------------------------------------------------
> ----------
> Without SSL connection, Normal SMTP
>
-----------------------------------------------------------------------
> --------
> import java.util.Properties;
> import javax.mail.*;
> import javax.mail.internet.*;
> import javax.activation.*;
> import java.io.UnsupportedEncodingException;
> import java.security.*;
> import java.util.Properties;
> import javax.mail.*;
> import javax.mail.internet.InternetAddress;
> import javax.mail.internet.MimeUtility;
> public class AttachExample {
> public static void main (String args[]) throws Exception
> {
> System.getProperties().put("proxySet","true");
> System.getProperties().put("socksProxyPort","1080"); // ip
> adresa a port proxy
> System.getProperties().put("socksProxyHost","192.168.155.1");
> Properties props = System.getProperties();
>
> String from = "[EMAIL PROTECTED]";
> String to = "[EMAIL PROTECTED]";
> String filename = "AttachExample.java";
>
>
> // Get system properties
> final String username = "USERNAME"; // jmeno a heslo z
> mailoveho uctu
> final String password = "PASSWORD";
>
> props.put("mail.user", username);
> props.put("mail.host", "smtp.seznam.cz");
> props.put("mail.debug", "true");
> props.put("mail.store.protocol", "pop3");
> props.put("mail.transport.protocol", "smtp");
>
>
> Session session = Session.getDefaultInstance(props,
> new Authenticator(){
> protected PasswordAuthentication
> getPasswordAuthentication() {
> return new
> PasswordAuthentication(username, password);
> }});
>
> // Define message
> Message message = new MimeMessage(session);
> message.setFrom(new InternetAddress(from));
> message.addRecipient(Message.RecipientType.TO, new
> InternetAddress(to));
> message.setSubject("Hello JavaMail Attachment");
> // Create the message part
> BodyPart messageBodyPart = new MimeBodyPart();
> // Fill the message
> messageBodyPart.setText("Here's the file");
> // Create a Multipart
> Multipart multipart = new MimeMultipart();
> // Add part one
> multipart.addBodyPart(messageBodyPart);
> // // Part two is attachment // // Create second body part
> messageBodyPart = new MimeBodyPart();
> // Get the attachment
> DataSource source = new FileDataSource(filename);
> // Set the data handler to the attachment
> messageBodyPart.setDataHandler(new DataHandler(source));
> // Set the filename
> messageBodyPart.setFileName(filename);
> // Add part two
> multipart.addBodyPart(messageBodyPart);
> // Put parts in message
> message.setContent(multipart);
> // Send the message
> Transport.send(message);
> }
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>