Wednesday, 7 August 2013

Google Apps Engine, Sending out Emails Receiving this Error (Attempt to access a blocked recipient without permission.) Java

Google Apps Engine, Sending out Emails Receiving this Error (Attempt to
access a blocked recipient without permission.) Java

I've figured out how to receive emails via Google Engine. Now I'm trying
to send out a confirmation that the email was received, but I keep getting
this error:
com.jkimgroup.emailtospreadsheet.MailHandlerServlet doPost:
MessagingException: javax.mail.SendFailedException: Send failure
(javax.mail.MessagingException: Could not connect to SMTP host: localhost,
port: 25 (java.net.SocketException: Permission denied: Attempt to access a
blocked recipient without permission.))
I have the "from" address set to my admin email. Is this an error message
where perhaps I'm not including the correct jar files in the /WEB-INF/lib
folder?
And I used google's standard example:
https://developers.google.com/appengine/docs/java/mail/usingjavamail
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
// ...
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
String msgBody = "...";
try {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("admin@example.com", "Example.com
Admin"));
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress("user@example.com", "Mr.
User"));
msg.setSubject("Your Example.com account has been activated");
msg.setText(msgBody);
Transport.send(msg);
} catch (AddressException e) {
// ...
} catch (MessagingException e) {
// ...
}

No comments:

Post a Comment