Make WordPress Core

Opened 14 years ago

Closed 8 years ago

#16805 closed defect (bug) (duplicate)

default 'from' hostname

Reported by: lonnylot's profile lonnylot Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Mail Keywords: needs-testing has-patch
Focuses: Cc:

Description

The logic used to create the hostname portion of default e-mail address when calling wp_mail doesn't make sense.

Lines 384-392 of wp-includes/pluggable.php read:

	if ( !isset( $from_email ) ) {
		// Get the site domain and get rid of www.
		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
			$sitename = substr( $sitename, 4 );
		}

		$from_email = 'wordpress@' . $sitename;
	}

We assume that if www. is in the sitename that it is not part of the e-mail address. I reviewed a few RFCs and have not found where 'www.' is prohibited from the hostname portion of an e-mail address. I concede that john.smith@ www.sitename.com is now common, but it is still a legal name.

Additionally, if the $_SERVER[ 'SERVER_NAME' ] is a sub-domain such as blogs.sitename.com the e-mail is going to send from john.smith@ blogs.sitename.com.

For consistency I suggest we either remove all nth level domain names above the first or remove none. This way it will be more obvious when people need to use the wp_mail_from filter and not just appear to be random.

Attachments (1)

16805.patch (892 bytes) - added by isdampe 10 years ago.

Download all attachments as: .zip

Change History (14)

#1 @dd32
14 years ago

  • Keywords close added

We assume that if www. is in the sitename that it is not part of the e-mail address. I reviewed a few RFCs and have not found where 'www.' is prohibited from the hostname portion of an e-mail address. I concede that john.smith@ www.sitename.com is now common, but it is still a legal name.

In general, 90% of hosts add www. as a add-on domain, and many simply skip it, it's just a generic subdomain.. in the majority of cases, user@domain.com is going to be more correct than user@www.domain.com, for the simple fact that the 'www.' is a generic domain for Web Hosting.

Additionally, if the $_SERVER[ 'SERVER_NAME' ] is a sub-domain such as blogs.sitename.com the e-mail is going to send from john.smith@ blogs.sitename.com.

That would be the expected behaviour for a a few reasons, the main one that sticks out to me is:

  • http://username.webhost.com/ => wordpress@webhost.com would be wrong

I don't see that anything here should change, it's not about what is legal in a email address, it's about what the majority of WordPress users expect/host supports.

Last edited 14 years ago by dd32 (previous) (diff)

#2 @toscho
14 years ago

  • Cc info@… added

There should be at least a check for domains like www.eu/com/net to avoid addresses like wordpress@com.

#3 @hakre
14 years ago

Thanks for reporting, it's obvioous that it can be done better than that. +1

#4 @lonnylot
14 years ago

dd32,

I do not think it is about what the majority of WordPress users expect/host supports. I am not trying to open up a can of worms, but if it was about what users expect/host supports than we wouldn't have WordPress default to wordpress@ hostname.com for things like the registration e-mail.

Sending an e-mail from wordpress@ hostname.com is no more user friendly than sending it from wordpress@ www.hostname.com or removing all subdomains by default and always sending it from wordpress@ hostname.com.

Again, I'm not trying to open this discussion up to that particular discussion. I am just trying to make a point that the handling isn't related to what users expect/hosts support.

Just Googling around it seems the amount of issues that people have with e-mails being rejected from the receiver are fairly high. The more I think about this I would rather do nothing with the hostname ($_SERVER[ 'SERVER_NAME' ]) than do something random.

I just wanted to give my 2 cents on this. Thanks for taking the time to review this bug. Please let me know if anyone has suggestions on implementation or anything you would like me to create anything such as a patch.

Last edited 14 years ago by lonnylot (previous) (diff)

#5 @lonnylot
13 years ago

Is there a place to create a WP RFC for this?

#6 @c3mdigital
11 years ago

  • Keywords needs-patch added; close removed

#8 @cmmarslender
11 years ago

  • Cc cmmarslender added

@isdampe
10 years ago

#9 @isdampe
10 years ago

  • Keywords needs-testing added

Please see attached patch to remove reliance on $_SERVER[ 'SERVER_NAME' ].

#10 @SergeyBiryukov
10 years ago

#29175 was marked as a duplicate.

#11 @chriscct7
9 years ago

  • Keywords has-patch added; needs-patch removed

#12 @cbutlerjr
8 years ago

@SergeyBiryukov has noted that #25239 is closely related to this and there is a recommended solution in that ticket. It addresses the issue of removing the use of $_SERVER['SERVER_NAME'] but in a more comprehensive way (it's actually used in the mail process in a few locations).

I suggest closing this as the fully implemented solution there should also resolve this.

#13 @SergeyBiryukov
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #25239.

Note: See TracTickets for help on using tickets.