Hi
I have the problem in responding automatic email response after create a new user. Although i set in the smtp setting, it doesn't work. Where should i check it for? Please advise me. Thanks in advance.

Comments

Michael M’s picture

I had similar problems. There are actually many forum topics covering this issue.

The problem is the configuration of the webserver or php or sendmail/gmail. The simplest fix is to change which smtp mailer is used in drupal.

Goto:
http://drupal.org/node/7294

and download the phpmailer.zip file. Read the "readme" file and follow the instructions.

----
http://LandCondos.com

ppa-1’s picture

Hi
I downloaded the zip file that you suggest and i could not find some files to modify. for instance,
3) modify conf.php and add following line:
$conf["smtp_library"] = "includes/phpmailer.inc";
where is that conf.php file? where should i add the above line?Can you please guide me in detail? I'm using Apache server and php ver. 5.
Thank you.

Michael M’s picture

Those instructions are for Drupal 4.5. You need to add that line to the sites/default/settings.php file.
1. Add this line to the settings.php file:

$conf["smtp_library"] = "includes/phpmailer.inc";

2. Upload a file called phpmailer.inc into the includes directory. Modify it to your settings. Sometimes, you might not have to modify anything. If you don't have it, it looks like this:

include_once 'includes/phpmailer/class.phpmailer.php';

function user_mail_wrapper($mail, $subject, $message, $header) {
  $mailer = new PHPMailer();                 // instantiate a new mailer
  $mailer->IsSMTP();                         // send via SMTP
  $mailer->Host     = "localhost";     // SMTP server
  $mailer->SMTPAuth = false;                 // turn on SMTP authentication

//  $mailer->Username = '';          // SMTP username
//  $mailer->Password = '';          // SMTP password
  $mailer->AddAddress($mail);                // can only send to one recipient 
  $mailer->From     = 'noreply@example.com'; // from address (default root@localhost)
  $mailer->FromName = 'example.com';    // from name (default 'root user')
  $mailer->Subject  = $subject;
  $mailer->AddCustomHeader( explode("\n", $header)); // add custom header info
  // if body is not formatted properly change str_replace - see user.module user_mail() for details
  $mailer->Body     = $message;//str_replace("\n", "\r\n", $message); // Body of message
  if(!$mailer->Send()){
    watchdog('error', 'mail send error: ' . $mailer->ErrorInfo);
    return false;
  }
  return true;
}

3. Upload the latest phpmailer files from sourceforge.net into the includes/phpmailer directory. My directory has 2 files: class.phpmailer.php and class.smtp.php

4. If you are designing modules, make sure you send email via the user_mail function like this:

if (user_mail($email, $subject, $message, "")) {
  drupal_set_message("Your message was sent to ". $email);
} else {
  drupal_set_message("Your message could not be sent to ". $email, "error");
}
ysanchez’s picture

I'm not a Linux geed and thus point 3 was difficult to achieve. I just would like to precise the includes/phpmailer directory is related to the PHP installation, not Drupal. E.g. in my case, the absolute path was: \lib\php\includes\phpmailer.

Michael M’s picture

Actually, it is in the drupal path, not the php path.

I think that the method you described (putting it in the php path) works because you configured PHP to use that. We are configuring drupal to use phpmailer.

----
http://PointHomes.com

leed’s picture

Does this work also when tested on localhost?
I may have made a mistake but I am getting 2 warnings.

    * warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\XAMPP\xampp\htdocs\xampp\drupal\includes\phpmailer\class.smtp.php on line 105.
    * warning: fsockopen() [function.fsockopen]: unable to connect to host.domain.ext:25 (Unknown error) in C:\XAMPP\xampp\htdocs\xampp\drupal\includes\phpmailer\class.smtp.php on line 105.
leed’s picture

I just fixed 2 warnings I had.
I forgot to change HOST to localhost.
Am I supposed to get an e-mail when I create a new account on localhost?