Qsmtp  0.30dev
Functions
addrparse.h File Reference

headers of address parser functions More...

#include <sstring.h>

Go to the source code of this file.

Functions

int checkaddr (const char *const)
 
int addrsyntax (char *in, const int flags, string *addr, char **more)
 check an email address for syntax errors More...
 
int addrspec_valid (const char *const addr)
 
int addrparse (char *in, const int flags, string *addr, char **more, struct userconf *ds, const char *, const off_t)
 check an email address for syntax errors and/or existence More...
 
int user_exists (const string *localpart, const char *domain, struct userconf *dsp)
 check if the user identified by localpart and ds->domainpath exists More...
 

Detailed Description

headers of address parser functions

Function Documentation

int addrparse ( char *  in,
const int  flags,
string addr,
char **  more,
struct userconf ds,
const char *  rcpthosts,
const off_t  rcpthsize 
)

check an email address for syntax errors and/or existence

Parameters
ininput to parse
flags
  • 0: mail from checks
  • 1: rcpt to checks (e.g. source route is allowed)
addrstruct string to contain the address (memory will be malloced, is set if 0 or -1 is returned)
morehere starts the data behind the first '>' behind the first '<' (or NULL if line ends after the '>')
dsstore the userconf of the user here
rcpthostsarray of the valid rcpthosts
rcpthsizesize of rcpthosts array
Returns
if address was validated
Return values
0address exists locally
>0on error (e.g. ENOMEM, return code is error code)
-2if address not local (this is of course no error condition for MAIL FROM)
-1if address local but nonexistent (expired or most probably faked) OR if domain of address does not exist (in both cases error is sent to network before leaving)

ds may be NULL in case the result is not interesting (e.g. if only checking MAIL FROM).

int addrspec_valid ( const char *const  addr)

check if the given string is a valid addr-spec

Parameters
addrstring to check
Returns
if string is valid addrspec
Return values
0string is invalid
1string is valid
int addrsyntax ( char *  in,
const int  flags,
string addr,
char **  more 
)

check an email address for syntax errors

Parameters
inaddress to parse
flags
  • 0: mail from checks,
  • 1: rcpt to checks (e.g. source route is allowed),
  • 2: checks for badmailfrom/goodmailfrom lists
addrstruct string to contain the address (memory will be malloced)
morehere starts the data behind the first '>' behind the first '<' (or NULL if none)
Returns
>0 on success
Return values
1address is empty (only possible if flags is 0)
3address is a full email address
4address is a full email address with IPv4 or IPv6 address literal
0in is invalid
-1an error occured (e.g. ENOMEM)
int checkaddr ( const char *const  addr)

check an email address for validity, use as loadlistfd callback

Parameters
addrthe address to check
Returns
if address valid
Return values
0address is valid
1address is invalid

This is just !parseaddr(addr). This allows this to be used as callback.

int user_exists ( const string localpart,
const char *  domain,
struct userconf dsp 
)

check if the user identified by localpart and ds->domainpath exists

Parameters
localpartlocalpart of mail address
domaindomainpart of the domain
dspath of domain
Return values
0user doesn't exist
1user exists
2mail would be catched by .qmail-default and .qmail-default != vpopbounce
3domain is not filtered (use for domains not local)
4mail would be catched by .qmail-foo-default (i.e. mailinglist)
5domain is not local
<0error code

If the user has it's own mail directory ds->userpath will be filled with the correct values.

This function must be implemented by the password backend (i.e. currently vpop.c).