My Drupal 5.5 installation resides on a GoDaddy economy hosting account.

When I created the first user, I did it several times because I was not getting the confirmation email. Eventually in frustration I just copied another Drupal password into this new install at the MySQL level to keep moving.

I've since installed the Webform module, but still - email refuses to work. No debug messages, no errors, nothing in the Drupal log. But no resulting email either.

I've installed the SMTP module, trying several configurations:

The Gmail Approach:

smtp.gmail.com, Port 465, Tried SSL and TLS, username@gmail.com - This yields (edited path, obviously):

* warning: fsockopen(): unable to connect to smtp.gmail.com:465 in /path/to/install/html/modules/smtp/smtp.module on line 1959.
* warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /path/to/install/html/modules/smtp/smtp.module on line 1959.
* warning: fsockopen(): unable to connect to :465 in /path/to/install/html/modules/smtp/smtp.module on line 1959.

The GoDaddy Approach:

I created an account called webmaster under my GoDaddy account with 250 relays. Tested the account with my mail client, works fine.

smtpout@secureserver.net, Port 80, no SSL (tried with SSL and TLS also), webmaster@mydomain.com - This doesn't yield an immediate SMTP error, but the logs report a failure:

Error sending email: 'The following From address failed: webmaster@mydomain.com' From: 'webmaster@mydomain.com' To: 'test@mydomain.com'

My SMTP Server Approach:

Using my own personal SMTP server which I know accepts outbound connections with authentication:

mail.myserver.net, Port 25, no SSL, myusername@myserver.net. This yields:

* warning: fsockopen(): unable to connect to mail.myserver.net:25 in /path/to/install/html/modules/smtp/smtp.module on line 1959.
* warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /path/to/install/html/modules/smtp/smtp.module on line 1959.
* warning: fsockopen(): unable to connect to :25 in /path/to/install/html/modules/smtp/smtp.module on line 1959.

So basically, my install has NO email functionality whatsoever... I'm seriously pulling my hair out here. Any ideas? :(

Comments

ceejayoz’s picture

Create a test PHP page with:

mail('you@you.com', 'Test', 'This is a test.');

That will send a test mail in the simplest possible way. If it does not work, GoDaddy has not set up their sendmail properly.

cmarcera’s picture

Thanks ceejayoz. I seem to be heading in a working direction. I ran that test:

mail('me@myaddress.com', 'Test', 'This is a test.')
  or die('FAILED');

And indeed got a failure message. So I did some searching on PHP.net and found this post:

http://us3.php.net/manual/en/ref.mail.php#79164

Which states:

Sending Email using PHP from Godaddy host

Hi guys this is what you have to use.

You need to use Pear thats already included on the godaddy hosting and then inlcude the mail.php

Here is a function to help you: This will even allow you to send html emails

require_once "Mail.php";

function emailHtml( $from, $subject, $message, $to ) {
  $host = "localhost";
  $username = "";
  $password = "";

  $headers = array ('MIME-Version' => "1.0", 'Content-type' => "text/html; charset=iso-8859-1;", 'From' => $from, 'To' => $to, 'Subject' => $subject);

  $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => false));

  $mail = $smtp->send($to, $headers, $message);
  if (PEAR::isError($mail))
    return 0;
  else
    return 1;
}

So that code in a test.php file, followed by:

emailHtml( "webmaster@myserver.com", "Test", "hello", "me@myaddress.com")

Executed fine and I got the email right away!

So now... I guess my question is where's Drupal's mail code located so I can make some modifications to make this work :/

amanuel’s picture

the function drupal_mail() can be found at : http://api.drupal.org/api/function/drupal_mail/5

I'd suggest your server config that indeed php is allowed to touch sendmail. See http://ca.php.net/mail

cheers.

cmarcera’s picture

I've edited my drupal_mail() function and at first glance I would think that it would work, or simply cut my page short. Here's what the end of the function now looks like in includes/common.inc:

    $mimeheaders = array();
    foreach ($headers as $name => $value) {
      $mimeheaders[] = $name .': '. mime_header_encode($value);
    }
	
    // Lines below Added until 'return mail('
    print( "Running altered script...<br>" );
    require_once "Mail.php";

    $headers['Subject'] = mime_header_encode($subject);

    $smtp = Mail::factory( 'smtp', array ('host' => 'localhost', 'auth' => false ) );

    $mail = $smtp->send( $to, $headers, str_replace("\r", '', $body) )
      or die( "MAIL FAILURE" );

    if( PEAR::isError( $mail ) ){
      return 0;
    } else {
      return 1;
    }

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

This code works on it's own and will send me an email. Note the print() command - it's almost as if drupal_mail() isn't even being called. Submitting my form just brings me to the "Thank you" page with no trace of "Running altered script..." and I've checked the source and that output text from the print() command is not in there. I've double checked to make sure the SMTP module I was trying to use is disabled. Just in case Drupal was using a cached common.inc, I deleted some crucial lines and refreshed a page. Sure enough it crashed and burned so I know the correct version of the file is being used.

Still losing hair *sigh*

jabevan’s picture

For what it's worth, I'm not positive this is a GoDaddy issue. I'm on a dedicated Rackspace server and experiencing the same thing. It's costing me lost of users who aren't going to wait 30 minutes+ for their email verification.

Josh Bevan
Only local images are allowed.

solman’s picture

.

jetlee2’s picture

visdvhsdiovhdsuivhduiovhsdh hgiinbh j hhjfii hjidhju hjsiops kkljopju huush id hfjj k

chinafocused’s picture

I'm having the same problem on Godaddy with ver 5.5 and also doing much hair pulling. I'm new to php, api, etc. so sorry I can't offer much help other than to add myself to the statistics.

fabianome’s picture

I was with the same problem, no emails sent by drupal system. But I decided to install the SMTP module, and now it's working perfectly!

ebenonce’s picture

All I find are people with the same problem, but nothing useful, surely there is a solution, thousands use Drupal daily, I don't want to have to give up!

webalchemist’s picture

smtpout.secureserver.net port 80 and no encryption. I added my account credentials below and it all seemed to work. I'm going to do some more testing now.