出现构建错误:
The type javax.mail.internet.MimeMessage cannot be resolved.
Run Code Online (Sandbox Code Playgroud)
它是从所需的 .class 文件间接引用的。
我该如何解决这个问题?看到一个类似的问题,建议添加一些罐子。但我使用的是 Maven。
Jakarta Mail ( https://eclipse-ee4j.github.io/mail/docs/api/ )的当前主页不再工作。
我听说名称已更改为 Eclipse Angus。
它的现状如何?
谢谢
我想知道我收到手机的手机名称(黑莓/ iPhone/ipad).如何识别手机名称?是否有标题来标识移动名称?
我读了那个电子邮件程序联系人的作者的ISP电子邮件服务器来传递它的消息.在下面的程序中,我与SMTP服务器成功连接gmail.我想从这个程序(从gmail帐户)发送电子邮件 到rediff帐户.没有在这个程序中我打开与rediff服务器的连接.但我成功发送了电子邮件.那个怎么样 ?我只是改变了测试,以从处理gmail到Rediff的和成功.这是程序:
// cross mail
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;
class crossmail {
public static void main(String args[]) {
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.stmp.user", "from");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.password", "password");
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props, new Athenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
String username = "from";
String password = "paassword";
return new PasswordAuthentication("from", "paassword");
}
}); …Run Code Online (Sandbox Code Playgroud) 我正在编写一个Java项目,用附件发送电子邮件.
在我的测试用例中,我将一些日语单词"some Hiraganas and Katakanas"添加到我附加的testfile.txt(我用UTF-8编码保存.)
但是当我打开附加的测试文件后,我将测试邮件发送给自己. txt,每个日本人的Chars都变成了"????".
所以我只是想知道为什么会发生这种情况......?
谢谢
艾伦
PS更具体,这是我的代码.我正在使用mail.jar发送电子邮件.
以下是我获取文件的方法:
/**
* Add an attachment to the Email.
* @param filePath
*/
public void setFile(String filePath){
attachment = new File(filePath);
}
Run Code Online (Sandbox Code Playgroud)
以下是我如何将文件附加到我的MIME电子邮件部分.
/*Add attachment if an attachment is given.*/
if(attachment != null){
MimeBodyPart attachmentPart = new MimeBodyPart();
attachmentPart.attachFile(attachment);
multipart.addBodyPart(attachmentPart);
}
Run Code Online (Sandbox Code Playgroud) 我发送消息到无效的电子邮件地址,但我没有任何异常.它的工作就像一切都很好,并且在调试器中它显示一切正常.
private MailService() {
Properties props = new Properties();
props.put("mail.transport.protocol", "smtps");
props.put("mail.smtps.host", HOST);
props.put("mail.smtps.auth", "true");
props.put("mail.smtp.from", FROM);
props.put("mail.smtps.quitwait", "false");
mailSession = Session.getDefaultInstance(props);
mailSession.setDebug(true);
}
public static void sendMessage(String recipient, String subject,
String message) throws MessagingException {
if (mailService == null) {
mailService = new MailService();
}
MimeMessage mimeMessage = new MimeMessage(mailSession);
mimeMessage.setFrom(new InternetAddress(FROM));
mimeMessage.setSender(new InternetAddress(FROM));
mimeMessage.setSubject(subject);
mimeMessage.setContent(message, "text/plain");
mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
Transport transport = mailSession.getTransport("smtps");
transport.connect(HOST, PORT, USER, PASSWORD);
transport.sendMessage(mimeMessage,
mimeMessage.getRecipients(Message.RecipientType.TO));
transport.close();
}
Run Code Online (Sandbox Code Playgroud)
我尝试了不同的电子邮件地址,并且尽管它没有抛出异常.我错了什么?
我有以下代码:
Email email = new SimpleEmail();
email.setHostName("smtp.googlemail.com");
email.setSmtpPort(465);
email.setAuthenticator(new DefaultAuthenticator("ruth.sistem@gmail.com", "XXXXXX"));
email.setSSLOnConnect(true);
email.setFrom("ruth.sistem@gmail.com");
email.setSubject("TestMail");
email.setMsg("This is a test mail ... :-)");
email.addTo("ruth.sistem@gmail.com");
email.send();
Run Code Online (Sandbox Code Playgroud)
我无法连接到gmail,连接出现错误突发,但是所有连接信息都是正确的,不知道什么阻止了我的代码发送电子邮件的连接,我不能发送简单的电子邮件,我没有丝毫的想法这是什么.
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.googlemail.com:465
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1410)
at org.apache.commons.mail.Email.send(Email.java:1437)
at com.observatorioLegislativo.util.EmailTeste.enviaEmailSimples(EmailTeste.java:27)
at com.observatorioLegislativo.util.EmailTeste.<init>(EmailTeste.java:13)
at com.observatorioLegislativo.bean.Teste.main(Teste.java:41)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.googlemail.com, port: 465;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1972)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Java Mail API和Gmail SMTP服务器发送邮件.这是我的代码:
final String username = "myusername@gmail.com";
final String password = "mypassword";
Properties props = new Properties();
props.put("mail.smtp.user", username);
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "25");
props.put("mail.debug", "true");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.EnableSSL.enable", "true");
props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.port", "465");
props.setProperty("mail.smtp.socketFactory.port", "465");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(username));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(clientEmail));
message.setSubject(subject);
message.setText("Dear "+clientName+",\n\n "+body);
Transport.send(message);
} catch (MessagingException e) {
throw new …Run Code Online (Sandbox Code Playgroud) 我在下面写了一个程序,通过java邮件api发送邮件,现在发送邮件我的查询是处理特殊情况也让我们说如果邮件没有发送然后我必须得到什么,如果邮件发送我必须做那个cas中的其他东西,现在请指教java mail api在发送邮件购买时证明了我们的任何参数我们可以检查邮件是否已成功发送,因为我已在我的程序中启用了调试
emailSession.setDebug(true);
Run Code Online (Sandbox Code Playgroud)
请告知哪个是java mail api发送的返回参数,我们可以检查邮件是否成功发送
下面是我简单的java邮件api程序
public class EmailTest {
public static void main(String[] args) {
String mailSmtpHost = "cakelycakes.com";
String mailTo = "bigcakes@cakelycakes.com";
String mailCc = "littlecakes@cakelycakes.com";
String mailFrom = "me@here.there.everywhere";
String mailSubject = "Email from Java";
String mailText = "This is an email from Java";
sendEmail(mailTo, mailCc, mailFrom, mailSubject, mailText, mailSmtpHost);
}
public static void sendEmail(String to, String cc, String from, String subject, String text, String smtpHost) {
try {
Properties properties = new Properties();
properties.put("mail.smtp.host", …Run Code Online (Sandbox Code Playgroud) 我尝试使用JavaMail API发送邮件时收到此错误:
javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
jakarta-mail ×10
java ×8
email ×3
blackberry ×1
encoding ×1
gmail ×1
ipad ×1
iphone ×1
jakarta-ee ×1
openshift ×1
sendmail ×1
text ×1
transport ×1