mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
use job_id as mail_id for SendableEmail -- it's only an internal id and job_id is unique enough.
This commit is contained in:
15
src/job.rs
15
src/job.rs
@@ -134,13 +134,8 @@ impl Job {
|
|||||||
/* connect to SMTP server, if not yet done */
|
/* connect to SMTP server, if not yet done */
|
||||||
if !context.smtp.lock().unwrap().is_connected() {
|
if !context.smtp.lock().unwrap().is_connected() {
|
||||||
let loginparam = LoginParam::from_database(context, "configured_");
|
let loginparam = LoginParam::from_database(context, "configured_");
|
||||||
if context
|
let connected = context.smtp.lock().unwrap().connect(context, &loginparam);
|
||||||
.smtp
|
if connected.is_err() {
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.connect(context, &loginparam)
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
self.try_again_later(3, None);
|
self.try_again_later(3, None);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -177,10 +172,10 @@ impl Job {
|
|||||||
// its ok/error response processing. Note that if a message
|
// its ok/error response processing. Note that if a message
|
||||||
// was sent we need to mark it in the database ASAP as we
|
// was sent we need to mark it in the database ASAP as we
|
||||||
// otherwise might send it twice.
|
// otherwise might send it twice.
|
||||||
let mut sock = context.smtp.lock().unwrap();
|
let mut smtp = context.smtp.lock().unwrap();
|
||||||
match sock.send(context, recipients_list, body) {
|
match smtp.send(context, recipients_list, body, self.job_id) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
sock.disconnect();
|
smtp.disconnect();
|
||||||
warn!(context, "smtp failed: {}", err);
|
warn!(context, "smtp failed: {}", err);
|
||||||
self.try_again_later(-1, Some(err.to_string()));
|
self.try_again_later(-1, Some(err.to_string()));
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/smtp.rs
14
src/smtp.rs
@@ -137,12 +137,13 @@ impl Smtp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// SMTP-Send a prepared mail to recipients.
|
/// SMTP-Send a prepared mail to recipients.
|
||||||
/// returns boolean whether send was successful.
|
/// on successful send out Ok() is returned.
|
||||||
pub fn send<'a>(
|
pub fn send<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
recipients: Vec<EmailAddress>,
|
recipients: Vec<EmailAddress>,
|
||||||
message: Vec<u8>,
|
message: Vec<u8>,
|
||||||
|
job_id: u32,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let message_len = message.len();
|
let message_len = message.len();
|
||||||
|
|
||||||
@@ -153,12 +154,15 @@ impl Smtp {
|
|||||||
.join(",");
|
.join(",");
|
||||||
|
|
||||||
if let Some(ref mut transport) = self.transport {
|
if let Some(ref mut transport) = self.transport {
|
||||||
let envelope = Envelope::new(self.from.clone(), recipients);
|
let envelope = match Envelope::new(self.from.clone(), recipients) {
|
||||||
ensure!(envelope.is_ok(), "internal smtp-message construction fail");
|
Ok(env) => env,
|
||||||
let envelope = envelope.unwrap();
|
Err(err) => {
|
||||||
|
bail!("{}", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
let mail = SendableEmail::new(
|
let mail = SendableEmail::new(
|
||||||
envelope,
|
envelope,
|
||||||
"mail-id".into(), // TODO: random id
|
format!("{}", job_id), // only used for internal logging
|
||||||
message,
|
message,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user