mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-15 18:13:57 +00:00
发送方邮箱允许自定义发件人昵称
This commit is contained in:
parent
bb8cb3c83e
commit
9d1122c6b3
@ -373,6 +373,8 @@ public class SenderActivity extends AppCompatActivity {
|
||||
if (emailSettingVo != null) switchEmailSSl.setChecked(emailSettingVo.getSsl());
|
||||
final EditText editTextEmailFromAdd = view1.findViewById(R.id.editTextEmailFromAdd);
|
||||
if (emailSettingVo != null) editTextEmailFromAdd.setText(emailSettingVo.getFromEmail());
|
||||
final EditText editTextEmailNickname = view1.findViewById(R.id.editTextEmailNickname);
|
||||
if (emailSettingVo != null) editTextEmailNickname.setText(emailSettingVo.getNickname());
|
||||
final EditText editTextEmailPsw = view1.findViewById(R.id.editTextEmailPsw);
|
||||
if (emailSettingVo != null) editTextEmailPsw.setText(emailSettingVo.getPwd());
|
||||
final EditText editTextEmailToAdd = view1.findViewById(R.id.editTextEmailToAdd);
|
||||
@ -402,6 +404,7 @@ public class SenderActivity extends AppCompatActivity {
|
||||
editTextEmailPort.getText().toString(),
|
||||
switchEmailSSl.isChecked(),
|
||||
editTextEmailFromAdd.getText().toString(),
|
||||
editTextEmailNickname.getText().toString(),
|
||||
editTextEmailPsw.getText().toString(),
|
||||
editTextEmailToAdd.getText().toString()
|
||||
);
|
||||
@ -418,6 +421,7 @@ public class SenderActivity extends AppCompatActivity {
|
||||
editTextEmailPort.getText().toString(),
|
||||
switchEmailSSl.isChecked(),
|
||||
editTextEmailFromAdd.getText().toString(),
|
||||
editTextEmailNickname.getText().toString(),
|
||||
editTextEmailPsw.getText().toString(),
|
||||
editTextEmailToAdd.getText().toString()
|
||||
);
|
||||
@ -452,15 +456,21 @@ public class SenderActivity extends AppCompatActivity {
|
||||
String fromemail = editTextEmailFromAdd.getText().toString();
|
||||
String pwd = editTextEmailPsw.getText().toString();
|
||||
String toemail = editTextEmailToAdd.getText().toString();
|
||||
|
||||
String nickname = editTextEmailNickname.getText().toString();
|
||||
if (nickname == null || nickname.equals("")) {
|
||||
nickname = "SmsForwarder";
|
||||
}
|
||||
|
||||
if (!host.isEmpty() && !port.isEmpty() && !fromemail.isEmpty() && !pwd.isEmpty() && !toemail.isEmpty()) {
|
||||
try {
|
||||
SenderMailMsg.sendEmail(0, handler, host, port, ssl, fromemail, pwd, toemail, "SmsForwarder Title", "测试内容(content)@" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
|
||||
SenderMailMsg.sendEmail(0, handler, host, port, ssl, fromemail, nickname, pwd, toemail, "SmsForwarder Title", "测试内容(content)@" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(SenderActivity.this, "发送失败:" + e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(SenderActivity.this, "token 不能为空", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(SenderActivity.this, "邮箱参数不完整", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -7,17 +7,19 @@ public class EmailSettingVo implements Serializable {
|
||||
private String port;
|
||||
private Boolean ssl = true;
|
||||
private String fromEmail;
|
||||
private String nickname;
|
||||
private String pwd;
|
||||
private String toEmail;
|
||||
|
||||
public EmailSettingVo() {
|
||||
}
|
||||
|
||||
public EmailSettingVo(String host, String port, Boolean ssl, String fromEmail, String pwd, String toEmail) {
|
||||
public EmailSettingVo(String host, String port, Boolean ssl, String fromEmail, String nickname, String pwd, String toEmail) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.ssl = ssl;
|
||||
this.fromEmail = fromEmail;
|
||||
this.nickname = nickname;
|
||||
this.pwd = pwd;
|
||||
this.toEmail = toEmail;
|
||||
}
|
||||
@ -54,6 +56,14 @@ public class EmailSettingVo implements Serializable {
|
||||
this.fromEmail = fromEmail;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getPwd() {
|
||||
return pwd;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class SendUtil {
|
||||
EmailSettingVo emailSettingVo = JSON.parseObject(senderModel.getJsonSetting(), EmailSettingVo.class);
|
||||
if (emailSettingVo != null) {
|
||||
try {
|
||||
SenderMailMsg.sendEmail(logId, handError, emailSettingVo.getHost(), emailSettingVo.getPort(), emailSettingVo.getSsl(), emailSettingVo.getFromEmail(),
|
||||
SenderMailMsg.sendEmail(logId, handError, emailSettingVo.getHost(), emailSettingVo.getPort(), emailSettingVo.getSsl(), emailSettingVo.getFromEmail(), emailSettingVo.getNickname(),
|
||||
emailSettingVo.getPwd(), emailSettingVo.getToEmail(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
||||
} catch (Exception e) {
|
||||
LogUtil.updateLog(logId, 0, e.getMessage());
|
||||
|
@ -14,9 +14,9 @@ import static com.idormy.sms.forwarder.SenderActivity.NOTIFY;
|
||||
public class SenderMailMsg {
|
||||
private static String TAG = "SenderMailMsg";
|
||||
|
||||
public static void sendEmail(final long logId, final Handler handError, final String host, final String port, final boolean ssl, final String fromemail, final String pwd, final String toAdd, final String title, final String content) {
|
||||
public static void sendEmail(final long logId, final Handler handError, final String host, final String port, final boolean ssl, final String fromemail, final String nickname, final String pwd, final String toAdd, final String title, final String content) {
|
||||
|
||||
Log.d(TAG, "sendEmail: host:" + host + " port:" + port + " ssl:" + ssl + " fromemail:" + fromemail + " pwd:" + pwd + " toAdd:" + toAdd);
|
||||
Log.d(TAG, "sendEmail: host:" + host + " port:" + port + " ssl:" + ssl + " fromemail:" + fromemail + " nickname:" + nickname + " pwd:" + pwd + " toAdd:" + toAdd);
|
||||
|
||||
try {
|
||||
//初始化框架
|
||||
@ -30,7 +30,7 @@ public class SenderMailMsg {
|
||||
|
||||
//设置一封草稿邮件
|
||||
Draft draft = new Draft()
|
||||
.setNickname("SmsForwarder") //发件人昵称
|
||||
.setNickname(nickname) //发件人昵称
|
||||
.setTo(toAdd) //收件人邮箱
|
||||
.setSubject(title) //邮件主题
|
||||
.setText(content); //邮件正文
|
||||
|
@ -95,7 +95,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="发件帐号" />
|
||||
android:text="发件人帐号" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextEmailFromAdd"
|
||||
@ -107,6 +107,28 @@
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="发件人昵称" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextEmailNickname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:ems="14"
|
||||
android:inputType=""
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user