#6829 closed defect (bug) (worksforme)
FromName causing emails not to send using Windows
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 2.5 |
| Component: | Keywords: | ||
| Focuses: | Cc: |
Description
I have a fresh install of 2.5, but was not getting any user/password related emails. I tracked this down to line 352 of pluggable.php which sets the FromName on the $phpmailer object. When this value is set, it causes email to be lost. When this value is set to null, then the email sends correctly.
php.ini is setup to use a remote SMTP server:
[mail function] ; For Win32 only. SMTP = 127.0.0.1 smtp_port = 25
Here is the modified code:
// Set the from name and email $phpmailer->From = apply_filters( 'wp_mail_from', $from_email ); $phpmailer->FromName = null; // <== this line changed
Change History (9)
#2
@
18 years ago
"Is the email not being sent at all? Does it show up in your spam folder?"
That is correct, PHP is not sending the email at all. No error message from the mail function either (I took out the '@' to see if I could get an error).
I think it has something to do with the fact that it is setting the FROM email address like
Mr. Smith <mr.smith@example.com>
I tested this on my local machine with the following script (obviously the email addresses where changed):
$to = 'person@example.com'; $subject = 'the subject'; $message = 'hello2'; $headers = 'From: Me <mr.smith@example.com>' . "\r\n" . 'Reply-To: mr.smith@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers);
When I ran the script on Windows with a similar php.ini setup, I got the following error message:
Warning: mail(): SMTP server response: 501 5.5.4 Invalid Address
When I set the from header to:
$headers = 'From: mr.smith@example.com' . "\r\n" .
The error went away and the email sent correctly. The mail() documentation warns about this:
Second, the custom headers like From:, Cc:, Bcc: and Date: are not interpreted by
the MTA in the first place, but are parsed by PHP.
As such, the to parameter should not be an address in the form of "Something
<someone@…>". The mail command may not parse this properly while talking
with the MTA.
#5
follow-up:
↓ 6
@
16 years ago
- Milestone changed from 2.9 to Future Release
Punting for time, and b/c no traction in 7 months. Is this still an issue?
#6
in reply to:
↑ 5
@
16 years ago
Replying to janeforshort:
Is this still an issue?
Technically, mail() on Windows can choke on from names. But wp_mail allows for a filter 'wp_mail_from_name' to change the default, which can also be used to correct this. wp_mail is also pluggable, so you can replace the whole thing.
I wonder if a more recent version of phpmailer accounts for the lack of FromName support in windows mail()?
#7
@
16 years ago
According to the PHP documentation for the mail() function:
4.3.0 (Windows only)
All custom headers (like From, Cc, Bcc and Date) are supported, and are not
case-sensitive. (As custom headers are not interpreted by the MTA in the first place,
but are parsed by PHP, PHP < 4.3 only supported the Cc header element and was
case-sensitive).
My guess is that the original poster was using something less that PHP 4.3.
#8
@
11 years ago
- Keywords close added; email removed
- Resolution set to worksforme
- Status changed from new to closed
No one has come forward with another report of it broken in over 4 years. The likelyhood is the reporter was not using a sufficient version of PHP, as described above, causing the error.
Is the email not being sent at all? Does it show up in your spam folder?