• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sending Email
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending Email


  • Subject: Re: Sending Email
  • From: Gino Pacitti <email@hidden>
  • Date: Mon, 11 Jul 2005 18:26:50 +0100

Hi LD

This is the class I am using and I load from a Properties file the smtp host, username and password..

Does this clarify the set up?



public static boolean send(String subject, String to, String from, String body) {
// these will be obtained from the Properties file
String mailHost = ((String)System.getProperties().getProperty ("mailHost"));
String mailSender = ((String)System.getProperties ().getProperty("mailSender"));
String mailPwd = ((String)System.getProperties().getProperty ("mailPwd"));


if ((from != null) && (to != null) && (subject != null) && (body != null)) {
try {
//Get system properties
Properties props = System.getProperties();
//Specify the desired SMTP server
props.put("mail.smtp.host", mailHost);
props.put("mail.smtp.auth", "true");
// create a new Session object
javax.mail.Session session = javax.mail.Session.getInstance(props,null);
// create a new MimeMessage object (using the Session created above)
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO, new InternetAddress[] { new InternetAddress(to) });
message.setRecipients(Message.RecipientType.BCC, new InternetAddress[] { new InternetAddress ((String)System.getProperties ().getProperty("toAddress")) });
message.setSubject(subject);
message.setContent(body, "text/plain");
message.setSentDate(new Date());
message.saveChanges();


Transport transport = session.getTransport("smtp");
transport.connect(mailHost,mailSender,mailPwd);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
return true;
}
catch (Throwable t) {
// t.printStackTrace();
System.err.println("SMTP: " + t);
return false;
}
}
return false;
}


On 11 Jul 2005, at 18:19, LD wrote:

Hi there,

On 12/07/2005, at 3:04 AM, Gino Pacitti wrote:


I have a class that utilizes:
javax.mail.*;
javax.mail.internet.*;
classes and has worked great until now.

I recently set up an xserve in a data centre and the ISP is handling the DNS etc...
But when I send through to the clients mail server using the correct mailserver, username and password I get this error:


javax.mail.SendFailedException: 550 5.7.1 <the email address to send to>... Relaying denied. IP name possibly forged [217.149.110.33]


The relay error seems to pop its head up when you're attempting to smtp via a network you're not a part of.
Are you sending via the ISP's smtp?


with regards,
--

LD




_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Sending Email
      • From: Lucas Holt <email@hidden>
References: 
 >Sending Email (From: Gino Pacitti <email@hidden>)
 >Re: Sending Email (From: LD <email@hidden>)

  • Prev by Date: Re: Sending Email
  • Next by Date: scp Automator workflows for Build and Upload .WOA apps...Enjoy!
  • Previous by thread: Re: Sending Email
  • Next by thread: Re: Sending Email
  • Index(es):
    • Date
    • Thread