Hide
original bugid: #6525
There is a startup-conflict in the standard SendMail module.
Normal operation:
- email gets inserted into database (by some mmbase install. on some machine)
- sendmail has a probe-time, wakes up
- checks whether there is mail, sends it
When the server gets restarted between step 1 and 2, sendmail gets woken up before it is initialized, resulting in a empty hostname, so no mail is send (it will abort and delete the mail).
Logfile:
----
10:26 INFO org.mmbase.module.core.MMBase: Starting builder : email
...
10:27 SERVICE org.mmbase.module.SendMail: SendMail connected to host=, port=25)
10:27 ERROR org.mmbase.module.SendMail: SendMail cannot connect to host=, port=25).java.net.ConnectException: Connection refused
...
10:27 INFO org.mmbase.util.logging.LoggerWrapper: Starting module sendmail
10:27 DEBUG org.mmbase.module.SendMail: Module SendMail started (mailhost=mailhost.vpro.nl)
----
Email does:
sendprobe=new EmailSendProbe(this);
EmailSendprobe:
start() -> run() -> checkProbe():
- tasks.removeElement(anode);
- parent.performTask(anode);
(parent = Email)
Email.performTask(emailnode) ->
- checkMailNode(node) does a
- sendMailNode(node) {
SendMailInterface sendmail=(SendMailInterface)Module.getModule("sendmail");
if (to==null || ((SendMailInterface)Module.getModule("sendmail")).sendMail(mail)==false) {
log.debug("Email -> mail failed");
}
Possible solution:
A solution would be to move the mailhost=getInitParameter("mailhost") to sendMail(mail) to be sure that mailhost gets set.
(fixed by Marcel Maatkamp)
I've fixed and verified the following:
sendMail(String from, String to, String data, Map headers) {
if(mailhost==null || mailhost.equals(""))
mailhost=getInitParameter("mailhost");
..
}
Also made the logfile more descriptive to what email gets send by sendmail-module. log.service will now print the 'from', 'to' and 'subject' to detect more easily a possible abuse or system-failure when sending mail (we seem to have another bug where email gets send twice).
Sendmail.log.service
print mail.'from', mail.'to', and mail.'subject'
Sendmail.log.debug
print connect.host, mail.from, mail.to, mail.subject and connect.status
I've set status to 'integrated' and move it to 'closed' after a couple of days.
Show
original bugid: #6525
There is a startup-conflict in the standard SendMail module.
Normal operation:
- email gets inserted into database (by some mmbase install. on some machine)
- sendmail has a probe-time, wakes up
- checks whether there is mail, sends it
When the server gets restarted between step 1 and 2, sendmail gets woken up before it is initialized, resulting in a empty hostname, so no mail is send (it will abort and delete the mail).
Logfile:
----
10:26 INFO org.mmbase.module.core.MMBase: Starting builder : email
...
10:27 SERVICE org.mmbase.module.SendMail: SendMail connected to host=, port=25)
10:27 ERROR org.mmbase.module.SendMail: SendMail cannot connect to host=, port=25).java.net.ConnectException: Connection refused
...
10:27 INFO org.mmbase.util.logging.LoggerWrapper: Starting module sendmail
10:27 DEBUG org.mmbase.module.SendMail: Module SendMail started (mailhost=mailhost.vpro.nl)
----
Email does:
sendprobe=new EmailSendProbe(this);
EmailSendprobe:
start() -> run() -> checkProbe():
- tasks.removeElement(anode);
- parent.performTask(anode);
(parent = Email)
Email.performTask(emailnode) ->
- checkMailNode(node) does a
- sendMailNode(node) {
SendMailInterface sendmail=(SendMailInterface)Module.getModule("sendmail");
if (to==null || ((SendMailInterface)Module.getModule("sendmail")).sendMail(mail)==false) {
log.debug("Email -> mail failed");
}
Possible solution:
A solution would be to move the mailhost=getInitParameter("mailhost") to sendMail(mail) to be sure that mailhost gets set.
(fixed by Marcel Maatkamp)
I've fixed and verified the following:
sendMail(String from, String to, String data, Map headers) {
if(mailhost==null || mailhost.equals(""))
mailhost=getInitParameter("mailhost");
..
}
Also made the logfile more descriptive to what email gets send by sendmail-module. log.service will now print the 'from', 'to' and 'subject' to detect more easily a possible abuse or system-failure when sending mail (we seem to have another bug where email gets send twice).
Sendmail.log.service
print mail.'from', mail.'to', and mail.'subject'
Sendmail.log.debug
print connect.host, mail.from, mail.to, mail.subject and connect.status
I've set status to 'integrated' and move it to 'closed' after a couple of days.