Hi, my development site is running on IIS with SMTP server. Mail is working fine when creating new users or getting a password reset. I have built a webform and upon submitting I'll get this error:

    * warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in C:\Inetpub\wwwroot\BHI_dev\includes\mail.inc on line 193.
    * Unable to send e-mail. Please contact the site admin, if the problem persists.

The address I use in my testing are in fact completely valid. Seems like webform is not playing nice with the core somehow. Further ideas?

Using Drupal 6.2.

Thanks.

Comments

Priority:Critical» Minor

This seems to be an IIS SMTP issue only. See here:

http://drupal.org/node/33967

Easy work around is to have no 'name' text , just the email address when you configure webform.
Think it may still be fixable at the code? I set it to 'minor' now.

Working great, one of the best modules around.

Title:Email Invalid Address"Name" <email@example.com> FROM name fails
Project:Webform» SMTP Authentication Support
Version:6.x-2.1.1» 6.x-1.0-beta3

Moving to the SMTP module.

To summarize, Webform users have not been able to send e-mails when using the SMTP module and the FROM e-mail addresses are formatted as "First Last" <email@example.com>. The name is properly mime_header_encoded when necessary.

Any users experiencing this issue, please update with the version of SMTP module you're using.

Version:6.x-1.0-beta3» 6.x-1.x-dev
Assigned:Unassigned» oadaeh
Priority:Minor» Normal

This is an FYI for all concerned parties. (This message is duplicated on the issues listed below. Read on for the why.)

I don't actually like the way the From e-mail address is handled in the code for the SMTP Authentication Support module. I have plans to change it, but because I think it will be a bit of a paradigm shift to change it so it works better and makes more sense, I was kind of waiting for my last massive changes is settle in a bit to see if they were causing anyone any problems before I potentially created more problems.

Although all the relevant issues are all pretty much duplicates of each other, there are some nuances in each that I want to capture in my work through the code. These are the relevant issues that I'll be working on together:
http://drupal.org/node/200415
http://drupal.org/node/279836
http://drupal.org/node/295655
http://drupal.org/node/300055

Just know that I will be working on these in the next month or so (sooner, if I get my current task list cleared up).

BTW, I'll be making the changes first in the 6.x branch. Once everything is settled, I'll backport them to the 5.x branch.

Thanks oadaeh, I'll redirect Webform users to this particular thread, as I get duplicates of this all the time also.

I've found that some modules like to use the format Name <mail@mail.com> or "Name" <mail@mail.com>. Both should work, and both are accepted by mail clients, so SMTP Module shouldn't force names to be quoted.

I've had to change the following line in order to allow mails to be sent from the Messaging module
$from_name = preg_replace('/"*(.*)"*\<(.*)\>/i',   '$1', $from); // It gives: Name

This simply changes the regular expression to ensure that quotes are optional.

Hope this helps.

Btw, it would be very useful if you could enhance this module to work with frameworks such as the Messaging framework that also has a PHPMailer plugin - but alas hasn't implemented authentication.

Thanks for a great module.

StatusFileSize
new724 bytes

The attached patch makes a minor change to the regex to fix this issue. If you review this or use this and it helps you, please mark it as Reviewed and Tested by the Community.

Version:6.x-1.x-dev» 6.x-1.0-beta3
Status:Active» Needs review

pretty sure those are still wrong.. :)

try this:

$from_name = preg_replace('/"?([^("\s)]*)"?.*$/', '$1', $from); // It gives: Name

Status:Needs review» Active

although, this still isn't handled correctly (i think by SMPT module)... as you can see in this example received email (Outlook):

http://screencast.com/t/LssiQdq5

even though the $from_name (Lifewire6) shows in email listing, it doesn't show in the actual email or when i double click to view the address: http://screencast.com/t/l5TzWzL7sijS

doesn't look as though class.phpmailer.php uses the $from_name anywhere.

Patch #6 solved my problem with this error! Thank you, rfay.

I copied the patch from comment 6 into my smtp folder, ran

patch < path_file_name.patch

and this did NOT work for me. The "from" name has a mysterious quote on the end (but not the beginning)

still pretty sure patch from #6 is wrong.

Status:Active» Needs review
StatusFileSize
new724 bytes

Fixed the patch with suggested line from liquidcms, please test this!

Priority:Normal» Critical

Thanks for this module - it's great! However, I am having the same problem that everyone else is having with webform module integration. I applied the patch in #13 to no effect. Here's the version that I'm running:

; Information added by drupal.org packaging script on 2009-11-12
version = "6.x-1.0-beta4"
core = "6.x"
project = "smtp"
datestamp = "1258043223"

The error (which remained unchanged before and after the patch) is a WSOD with a single line that says:

Invalid address: "name"

I'd be happy to pitch in trying to test other things (and I don't mind screwing around with code on my site), but I would need to be pointed in the right direction.

Thanks!

I tried using the dev version, and it worked (no patch needed). Give that a go if you're having trouble.

Version:6.x-1.0-beta3» 6.x-1.0-beta4

Trying the dev version dated 2010-Jan-04 gives me:

Fatal error: require_once() [function.require]: Failed opening required 'sites/default/modules/smtp/phpmailer/class.phpmailer.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/spagent_biz/sites/default/modules/smtp/smtp.module on line 266

@yountod: Is it possible you haven't installed the phpmailer package? Please read the INSTALL.txt in that case.

Oooof, I was using the SMTP relay module - I'm in an installation where I am forced to use SMTP off a separate box. Disregard my comment, then, I think?

Status:Needs review» Fixed

The patch was already commited, I'll close the issue

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Version:6.x-1.0-beta4» 6.x-1.0-beta5
Status:Closed (fixed)» Active

Is it just me? I've updated to the latest version, 6.x-1.0-beta5, but it still is not fixed for me. My webforms have "Site Name" in the "From Name" field and they work fine with regular mail but through SMTP they only show "Site" in the "From" field of the e-mail.

I tried changing out the regex to the patch in #6, and that mostly worked, but like checkmark says in #11, it worked except there was an extra double-quote at the end.

At least for me, the committed changes did nothing for me to resolve this problem. Anyone else been able to fix this? Anyone still having the issue?

A quick fix for Webform users is just to use "short" e-mail format, configurable under the advanced settings at admin/settings/webform.

quicksketch, I don't see that option, but I guess we're using the 6.x-2.x series and not the new 6.x-3.x series instead. I'll have to check out the new version sometime soon; thanks for the input!

StatusFileSize
new694 bytes

None of the existing patches worked for me.

This, however, seemed to do the trick...
$from_name = preg_replace('/("([^"]*)")|(([^("\s)]*))\s*\<.*\>$/', '$2$4', $from);

Assigned:oadaeh» José San Martin
Status:Active» Postponed (maintainer needs more info)

I've tested with the most recent version of webform (6.x-3.4) and SMTP 6.x-1.x-dev.

Your regex seems to be correct and I've tested it successfully, but I don't know if it's needed.

Can you please provide more information to help me reproduce the bug? What are you using with SMTP? What's in the $from variable when you run that regex?

The $from variable contains a string of the form:

Name <email@address.com> or
First Last <email@address.com>

The previous regexes were failing on strings of the second form and returning the entire string (rather than just "First Last" as they should).

Priority:Critical» Normal

Resetting stats.

This patch solved my issue!
Thanks

$from_name = preg_replace('/("([^"]*)")|(([^("\s)]*))\s*\<.*\>$/', '$2$4', $from); // It gives: Name

This patch solved my issue!
Thanks

the patch from above works.

It could be simplified probably, but it just works!

using : version = "6.x-1.0-beta5"

Status:Postponed (maintainer needs more info)» Reviewed & tested by the community

I've tested it, it works for me as well :)

Status:Reviewed & tested by the community» Fixed

Commited to dev.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.