473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with sending of password reminder emails

Hi all,

I have recently set up a Drupal website. I am a beginner. My shared
host server does not allow nobody@localhost to send emails, and
prevents access to php.ini, so I spent some time getting a SMTP script
running. While the Drupal feedback module and the new account creation
works fine in terms of sending of mails, I am having some problems with
the sending of password reminder emails.

warning: Cannot modify header information - headers already sent by
(output started at
/home/affyorg/public_html/cancer/content/mail.php:20) in
/home/affyorg/public_html/cancer/content/includes/common.inc on line
192.

Your advice would be appreciated. Thanks!!

My mail.php file is as follows:
<?
include("Mail.php");
$recipients = $mail;
$headers["To"] = $mail;
$headers["From"] = "ab*@xyz.org";
$headers["Subject"] = $subject;
$body = str_replace("\n", "\r\n", $message);
$params["host"] = "mail.xyz.org";
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = "ab*@xyz.org";
$params["password"] = "defgh";
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $params);
$mail_object->send($recipients, $headers, $body);
?>

Line 189 - 192 of common.inc is

// Before the redirect, allow modules to react to the end of the page
request.
module_invoke_all('exit', $url);

header('Location: '. $url);

The Drupal user.module has the following code for password reminders

// Mail new password:
$variables = array('%username' => $account->name, '%site' =>
variable_get('site_name', 'drupal'), '%password' => $pass, '%uri' =>
$base_url, '%uri_brief' => substr($base_url, strlen('http://')),
'%mailto' => $account->mail, '%date' => format_date(time()),
'%login_uri' => url('user', NULL, NULL, TRUE), '%edit_uri' =>
url('user/'. $account->uid .'/edit', NULL, NULL, TRUE));
$subject = _user_mail_text('pass_subject', $variables);
$body = _user_mail_text('pass_body', $variables);
$headers = "From: $from\nReply-to: $from\nX-Mailer:
Drupal\nReturn-path: $from\nErrors-to: $from";
$mail_success = user_mail($account->mail, $subject, $body,
$headers);

if ($mail_success) {
watchdog('user', t('Password mailed to %name at %email.',
array('%name' => theme('placeholder', $account->name), '%email' =>
theme('placeholder', $account->mail))));
drupal_set_message(t('Your password and further instructions have
been sent to your e-mail address.'));
}
else {
watchdog('user', t('Error mailing password to %name at %email.',
array('%name' => theme('placeholder', $account->name), '%email' =>
theme('placeholder', $account->mail))), WATCHDOG_ERROR);
drupal_set_message(t('Unable to send mail. Please contact the
site admin.'));
}

Nov 22 '05 #1
4 3107
splicemix wrote:
Hi all,

I have recently set up a Drupal website. I am a beginner. My shared
host server does not allow nobody@localhost to send emails, and
prevents access to php.ini, so I spent some time getting a SMTP script
running. While the Drupal feedback module and the new account creation
works fine in terms of sending of mails, I am having some problems with
the sending of password reminder emails.

warning: Cannot modify header information - headers already sent by
(output started at
/home/affyorg/public_html/cancer/content/mail.php:20) in
/home/affyorg/public_html/cancer/content/includes/common.inc on line
192.

Your advice would be appreciated. Thanks!!

My mail.php file is as follows:
<?
include("Mail.php");
$recipients = $mail;
$headers["To"] = $mail;
$headers["From"] = "ab*@xyz.org";
$headers["Subject"] = $subject;
$body = str_replace("\n", "\r\n", $message);
$params["host"] = "mail.xyz.org";
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = "ab*@xyz.org";
$params["password"] = "defgh";
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $params);
$mail_object->send($recipients, $headers, $body);
?>

Line 189 - 192 of common.inc is

// Before the redirect, allow modules to react to the end of the page
request.
module_invoke_all('exit', $url);

header('Location: '. $url);

The Drupal user.module has the following code for password reminders

// Mail new password:
$variables = array('%username' => $account->name, '%site' =>
variable_get('site_name', 'drupal'), '%password' => $pass, '%uri' =>
$base_url, '%uri_brief' => substr($base_url, strlen('http://')),
'%mailto' => $account->mail, '%date' => format_date(time()),
'%login_uri' => url('user', NULL, NULL, TRUE), '%edit_uri' =>
url('user/'. $account->uid .'/edit', NULL, NULL, TRUE));
$subject = _user_mail_text('pass_subject', $variables);
$body = _user_mail_text('pass_body', $variables);
$headers = "From: $from\nReply-to: $from\nX-Mailer:
Drupal\nReturn-path: $from\nErrors-to: $from";
$mail_success = user_mail($account->mail, $subject, $body,
$headers);

if ($mail_success) {
watchdog('user', t('Password mailed to %name at %email.',
array('%name' => theme('placeholder', $account->name), '%email' =>
theme('placeholder', $account->mail))));
drupal_set_message(t('Your password and further instructions have
been sent to your e-mail address.'));
}
else {
watchdog('user', t('Error mailing password to %name at %email.',
array('%name' => theme('placeholder', $account->name), '%email' =>
theme('placeholder', $account->mail))), WATCHDOG_ERROR);
drupal_set_message(t('Unable to send mail. Please contact the
site admin.'));
}


Like your message says - something on mail.php line 20 caused output to
be sent the browser. It could be a blank line, for instance.

Fix that and it should work - or at least go onto the next line.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 22 '05 #2
Hmmm. It seems that it was something to do with sending files in
binary. In any case, thanks! This "header" error is resolved, but I am
still getting the message "Unable to send mail. Please contact the site
admin."

Based on the Drupal code in user.module, this happens when
($mail_success) is false. I can't quite see why $mail_success should be
false, since I do get the password change mail.

Any advice on how to troubleshoot this would be very welcome!

Nov 22 '05 #3
splicemix wrote:
Hmmm. It seems that it was something to do with sending files in
binary. In any case, thanks! This "header" error is resolved, but I am
still getting the message "Unable to send mail. Please contact the site
admin."

Based on the Drupal code in user.module, this happens when
($mail_success) is false. I can't quite see why $mail_success should be
false, since I do get the password change mail.

Any advice on how to troubleshoot this would be very welcome!


Unfortunately, I don't use the Drupal code, and am not familiar with how
it works. So I'm afraid I can't help you much.

But I would start by looking at both the mail program's (i.e. sendmail,
exim, whatever) log to see if there's anything in there.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 23 '05 #4
Look in Drupal's website.
If you can't find anything, use a Drupal forum, or ask in Drupal
support.
They know their code better than we do.

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Fabio Papa | last post by:
I am trying to write a windows service that sends emails to clients at specific times based on information in a sql db. Since this is done for multiple cities, I start a thread for each city and...
5
by: BaWork | last post by:
I have a web form where a client can select which site members to send an email to. This form is populated from the contents of the member table, so the form can have 0-x names listed on it...
6
by: Mike the Canadian | last post by:
I am having a very strange problem sending email with php. I have two domains. I can send an email to one domain using php but not the other. If I put both email addresses in the mail command only...
3
by: Arek | last post by:
Hey, I have a question, what are the possibilities of sending emails using ASP.net. (and VB.net) What I think is that user can send automatic reminder if he check box on the form and submit. Do...
6
by: Eduardo Rosa | last post by:
Somebody knows how I queue email using .Net? thanks a lot
5
by: Mark A. Sam | last post by:
Hello, I am sending two emails from the same procedure, one to myself (while testing) and another (a comfirmation) to the user on the website. I was having difficulty finding a relay server to...
3
by: armando perez | last post by:
Hi, this is my first time here, but I was looking for something that may help me, and still, I haven't found something to use. I'm using a website made in .NET with C#, when I'm running my site...
2
by: samvb | last post by:
Hello Guys, This is more a problem with Argosoft Mail Server Pro. I was able to send email from my php and I can see list of all emails sent in the Argosoft Emails window. But after recieiving the...
1
by: THEAF | last post by:
hi, i'm trying to create a reminder form on vb6 with access holding the reminders. i was given a code that checks the list box where all the reminders are shown on vb to see if any of the reminders...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.