I'm getting the following error when I try to send mail with Mass Contact 5.x-2.4-beta on a Drupal 5.2 installation:

cid = "1"
1 errors encountered sending message. Please check the logs and try again.
warning: mail() [function.mail]: SMTP server response: 501 syntax error in C:\websites\www\includes\common.inc on line 1979.

This is the section of code that it points to:

...
    return mail(
      $to,
      mime_header_encode($subject),
      str_replace("\r", '', $body),
      join("\n", $mimeheaders)
    );
...

The comments above this section talk about line-break differences between Windows and Linux servers ("\r\n" as opposed to "\n"), but I do not believe that this part of the code is at fault because the site can send out registration emails just fine. Nonetheless, I have played with the str_replace arguments considerably, but to no avail.

Thanks in advance!

Comments

eromba’s picture

It turns out that this issue was due to the format of the "to" header that Mass Contact uses. This module sends emails using the address format "Username " (without the quotes). For example: "John Doe ". However, it appears that Windows servers will only work with the email sent to: "john@~.com" (again, without quotes).

Thus, I had to change the following in mass_contact.module:

~Line 904:

        foreach ($recipientouta as $rnamea => $rmaila) {
          $recipientout[] = $rnamea ." <". $rmaila .">";
          $recipient_temp[] = $rnamea ." <". $rmaila .">";
          $countrecip = count($recipient_temp);

to...

        foreach ($recipientouta as $rnamea => $rmaila) {
          $recipientout[] = $rmaila;
          $recipient_temp[] = $rmaila;
          $countrecip = count($recipient_temp);

And then around line 973:

      else {
        foreach ($recipientouta as $rnamea => $rmaila) {
          $recipientout[] = $rnamea ." <". $rmaila .">";
        }

to...

      else {
        foreach ($recipientouta as $rnamea => $rmaila) {
          $recipientout[] = $rmaila;
        }

I hope this helps others with the same problem!

oadaeh’s picture

Do you have the SMTP Authentication Support module installed? If so, your error is because of it. I will be working on correcting the bugs in that module very soon.

oadaeh’s picture

Status: Active » Fixed

I fixed this and submitted the changes to the head of the 2.x branch yesterday.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

snohio’s picture

The SMTP Module does fix this issue as well. Looks like a problem with the way Microsoft IIS/SMTP handles the RCPT TO: address. I posted some information from the logs here: http://drupal.org/node/33967. Simple solution is to install the SMTP module.. Thanks!!