On 03/20/2013 06:45 PM, Patrick Lists wrote:
[snip]]
I've setup postfix with dspam and openldap and because I get email for a
couple of domains it uses email addresses as a login. Now I could not
figure out how to make this work with canned notices like firstrun.txt.
It seems impossible using only %u to set a proper From: address, address
where to send spam too (spam@...) and URL of the web interface.
Bad netiquette to reply to my own question but I came up with a patch
that works for me. Maybe it helps others too. Just replace the domain in
the canned notices with $d and dspam should fill in the domain extracted
from the user's username (if username is an email address).
Use at own risk and please excuse my C :-) Improvements to the patch
most welcome.
diff -uNr dspam-3.10.2.org/src/dspam.c dspam-3.10.2/src/dspam.c
--- dspam-3.10.2.org/src/dspam.c 2012-04-11 20:48:33.000000000 +0200
+++ dspam-3.10.2/src/dspam.c 2013-03-26 16:30:32.750999991 +0100
@@ -1569,6 +1569,18 @@
buffer_cat(b, buf);
while(fgets(buf, sizeof(buf), f)!=NULL) {
+
+ /* check for '@' in username and grab the domain if found */
+ char *at_sign = strstr(username, "@");
+ int length = strlen(at_sign) + 1;
+ char mydomain[length];
+ if (at_sign != NULL) {
+ /* LOGDEBUG ("The '@' sign was found in username %s", username); */
+ mydomain[length] = 0;
+ strncpy(mydomain, at_sign + 1, strlen(at_sign) - 1);
+ /* LOGDEBUG ("The domain is: %s", mydomain); */
+ }
+
char *s = buf;
char *w = strstr(buf, "$u");
while(w != NULL) {
@@ -1578,6 +1590,19 @@
s = w+2;
w = strstr(s, "$u");
}
+ /* replace $d with mydomain */
+ if (at_sign != NULL) {
+ /* LOGDEBUG ("Replacing $d with %s", mydomain); */
+ char *wxw = strstr(buf, "$d");
+ while(wxw != NULL) {
+ wxw[0] = 0;
+ buffer_cat(b, s);
+ buffer_cat(b, mydomain);
+ s = wxw+2;
+ wxw = strstr(s, "$d");
+
+ }
+ }
buffer_cat(b, s);
}
fclose(f);
Regards,
Patrick
diff -uNr dspam-3.10.2.org/src/dspam.c dspam-3.10.2/src/dspam.c
--- dspam-3.10.2.org/src/dspam.c 2012-04-11 20:48:33.000000000 +0200
+++ dspam-3.10.2/src/dspam.c 2013-03-26 16:30:32.750999991 +0100
@@ -1569,6 +1569,18 @@
buffer_cat(b, buf);
while(fgets(buf, sizeof(buf), f)!=NULL) {
+
+ /* check for '@' in username and grab the domain if found */
+ char *at_sign = strstr(username, "@");
+ int length = strlen(at_sign) + 1;
+ char mydomain[length];
+ if (at_sign != NULL) {
+ /* LOGDEBUG ("The '@' sign was found in username %s", username); */
+ mydomain[length] = 0;
+ strncpy(mydomain, at_sign + 1, strlen(at_sign) - 1);
+ /* LOGDEBUG ("The domain is: %s", mydomain); */
+ }
+
char *s = buf;
char *w = strstr(buf, "$u");
while(w != NULL) {
@@ -1578,6 +1590,19 @@
s = w+2;
w = strstr(s, "$u");
}
+ /* replace $d with mydomain */
+ if (at_sign != NULL) {
+ /* LOGDEBUG ("Replacing $d with %s", mydomain); */
+ char *wxw = strstr(buf, "$d");
+ while(wxw != NULL) {
+ wxw[0] = 0;
+ buffer_cat(b, s);
+ buffer_cat(b, mydomain);
+ s = wxw+2;
+ wxw = strstr(s, "$d");
+
+ }
+ }
buffer_cat(b, s);
}
fclose(f);
------------------------------------------------------------------------------
Own the Future-Intel® Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game
on Steam. $5K grand prize plus 10 genre and skill prizes.
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
Dspam-user mailing list
Dspam-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspam-user