I'm trying to send and email with javamail api. The code is very simple but when I send the mail doesn't work. Show this error message:
com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.1 Client does not have permissions to send
as this sender
The code is this:
public class Email {
static Properties mailServerProperties;
static Session getMailSession;
static MimeMessage generateMailMessage;
static String aInc = "scanner@impresia.es";
public void sendEmail(String a, String c) throws AddressException, MessagingException {
// Server propierties
mailServerProperties = System.getProperties();
mailServerProperties.put("mail.smtp.port", "25");
mailServerProperties.put("mail.smtp.auth", "true");
// New mail
getMailSession = Session.getDefaultInstance(mailServerProperties, null);
generateMailMessage = new MimeMessage(getMailSession);
generateMailMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(aInc));
generateMailMessage.setSubject(c);
generateMailMessage.setContent(a, "text/html");
// Send Email
Transport transport = getMailSession.getTransport("smtp");
transport.connect("10.5.32.40", "scanner@impresia.es", "xxxxxxxx");
transport.sendMessage(generateMailMessage, generateMailMessage.getAllRecipients());//generateMailMessage.getAllRecipients());
transport.close();
}
}
Please, could you help me?
Thanks!
在MimeMessage中设置发件人地址后,您可以尝试发送邮件。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.