What is the problem and how to fix it?

If the headers are not set, user_mail_wrapper initializes $from_name using site's 'site_name' variable. Unfortunately it forgets to pick up 'site_mail' which leads to corrupted "FROM" setting in the received email.

Solution is simple, use this code for seting default email (added one line only):

	if (variable_get('smtp_fromname', '') != ''){
    $from_name = variable_get('smtp_fromname', '');
	}
	else{
	  $from = variable_get('site_mail', '');
	  $from_name = variable_get('site_name', '');
	}

Perhaps $from should also be populated on IF == TRUE, but I am not sure how write the parser...

Comments

LukeLast’s picture

Assigned: Unassigned » LukeLast
Status: Reviewed & tested by the community » Fixed

I can see how that could be a problem. I updated the latest version of SMTP 4.7 to use the site_mail value when a from address isn't given in the header.

Anonymous’s picture

Status: Fixed » Closed (fixed)