android - 使用 jar 库的 android 应用程序中的电子邮件传递问题
问题描述
我正在开发一个使用 jar 库发送电子邮件的应用程序。我正在使用自定义电子邮件帐户从 android 应用程序发送电子邮件。以下是发送者活动的代码
private String mailhost = "us2.smtp.mailhostbox.com";
public GMailSender(String user, String password) {
this.user = user;
this.password = password;
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mailhost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "587");
props.put("mail.smtp.socketFactory.port", "587");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");
session = Session.getDefaultInstance(props, this);
}
以下代码用于设置发件人和收件人
final ProgressDialog pd = ProgressDialog.show(MessageActivity.this,"Sending...", "Please Wait...",true);
new Thread(new Runnable() {
public void run() {
try {
GMailSender sender = new GMailSender("apps@softglobe.net", "XXXXXX");
//sender.addAttachment(Environment.getExternalStorageDirectory().getPath()+"/image.jpg");
sender.sendMail("New Message from Arsod Classes App", "New Message from Arsod Classes App\nName: " + nm + "\nEmail: " + em + "\nMessage: " + msg,
"apps@softglobe.net", "softglobe.technologies@gmail.com");
MessageActivity.this.runOnUiThread(new Runnable() {
public void run() {
pd.dismiss();
Toast.makeText(getApplicationContext(), "Mail Sent successfully!", Toast.LENGTH_LONG).show();
}
});
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
}
}
}).start();
当我尝试使用上述代码发送电子邮件时,Toast
出现“电子邮件已发送”,但我没有在收件人一侧接收。同样,当我尝试使用php
网站和phpmailer
库发送具有相同凭据的电子邮件时,电子邮件发送成功。可能是什么问题?请帮忙。我花了很多时间,但没有找到任何解决方案。我正在使用 google 提供的 jar 库作为activation.jar
,additional.jar
和mail.jar
.
解决方案
推荐阅读
- javascript - Bots 是否能够清除本地存储?
- unit-testing - 我如何以及应该如何重用单元测试
- javascript - Elasticsearch:如何使用javascript客户端以降序表示search_after中未定义的日期?
- python - 如何启动 Quart Telethon 示例项目?
- git - 403 禁止的 npm - cicd
- java - Java 流抛出 java.lang.IllegalStateException: Duplicate key
- discord.py - 我在使用列出 CS 1.6 服务器上的玩家的不和谐机器人时遇到问题
- autodesk-forge - 是否可以自定义 Forge 查看器版本 7 的加载微调器?
- outlook - 在线托管的 Outlook 签名图像不刷新?
- regex - 为显示名称构建正则表达式