In general, the situation is this, I am sending letters via javax.mail, I’ll give you a piece of code:
Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(fromMail)); msg.setRecipient(Message.RecipientType.TO, new InternetAddress(toMail)); msg.setSubject(Subject); MimeBodyPart msgPart = new MimeBodyPart(); MimeMultipart multipart = new MimeMultipart(); multipart.addBodyPart(msgPart); msgPart.setText(bodyMail, "UTF-8"); msgPart.setHeader("Content-Type", "text/html; charset=\"utf-8\""); msg.setContent(multipart); Transport transport = session.getTransport("smtp"); transport.connect(smtp_host, smtp_port, smtp_user, smtp_pass); msg.saveChanges(); transport.sendMessage(msg, msg.getAllRecipients()); The question is how do I substitute the sender's name in the FROM field, i.e. that was
FROM: Vasya Pupkin pupkin@mail.com
I can not figure out that setFrom () can have an argument only InternetAddress :( Can it be somehow through setHeader ()?