473,554 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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@localhos t 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.p hp");
$recipients = $mail;
$headers["To"] = $mail;
$headers["From"] = "ab*@xyz.or g";
$headers["Subject"] = $subject;
$body = str_replace("\n ", "\r\n", $message);
$params["host"] = "mail.xyz.o rg";
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = "ab*@xyz.or g";
$params["password"] = "defgh";
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory(" smtp", $params);
$mail_object->send($recipien ts, $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_a ll('exit', $url);

header('Locatio n: '. $url);

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

// Mail new password:
$variables = array('%usernam e' => $account->name, '%site' =>
variable_get('s ite_name', 'drupal'), '%password' => $pass, '%uri' =>
$base_url, '%uri_brief' => substr($base_ur l, strlen('http://')),
'%mailto' => $account->mail, '%date' => format_date(tim e()),
'%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($acco unt->mail, $subject, $body,
$headers);

if ($mail_success) {
watchdog('user' , t('Password mailed to %name at %email.',
array('%name' => theme('placehol der', $account->name), '%email' =>
theme('placehol der', $account->mail))));
drupal_set_mess age(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('placehol der', $account->name), '%email' =>
theme('placehol der', $account->mail))), WATCHDOG_ERROR) ;
drupal_set_mess age(t('Unable to send mail. Please contact the
site admin.'));
}

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

I have recently set up a Drupal website. I am a beginner. My shared
host server does not allow nobody@localhos t 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.p hp");
$recipients = $mail;
$headers["To"] = $mail;
$headers["From"] = "ab*@xyz.or g";
$headers["Subject"] = $subject;
$body = str_replace("\n ", "\r\n", $message);
$params["host"] = "mail.xyz.o rg";
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = "ab*@xyz.or g";
$params["password"] = "defgh";
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory(" smtp", $params);
$mail_object->send($recipien ts, $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_a ll('exit', $url);

header('Locatio n: '. $url);

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

// Mail new password:
$variables = array('%usernam e' => $account->name, '%site' =>
variable_get('s ite_name', 'drupal'), '%password' => $pass, '%uri' =>
$base_url, '%uri_brief' => substr($base_ur l, strlen('http://')),
'%mailto' => $account->mail, '%date' => format_date(tim e()),
'%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($acco unt->mail, $subject, $body,
$headers);

if ($mail_success) {
watchdog('user' , t('Password mailed to %name at %email.',
array('%name' => theme('placehol der', $account->name), '%email' =>
theme('placehol der', $account->mail))));
drupal_set_mess age(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('placehol der', $account->name), '%email' =>
theme('placehol der', $account->mail))), WATCHDOG_ERROR) ;
drupal_set_mess age(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*******@attgl obal.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*******@attgl obal.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
2017
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 continue the processing from each thread. My service starts fine (gives me no errors, etc), but it doesn't seem to start the new threads. I am new...
5
2611
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 depending on member expiration dates. When the form is submitted, the code loops through the form contents and sends an email to those members that...
6
2031
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 the one email will arrive. I can send emails the traditional way to the problem domain and they arrive fine. Is there anything that might explain...
3
394
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 I need to have SMTP server? Can it be done without using of SMTP, something similar to automation in VB? I tried before for quite a few days to...
6
2401
by: Eduardo Rosa | last post by:
Somebody knows how I queue email using .Net? thanks a lot
5
4874
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 SMTP though, but was able to do this though one of my personal account, Cabbage.Org. It doesn't make any sense to me why this works and no other...
3
4264
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 from my PC, everything seems right, but when I publish the website, and send it to my real website, everything works but the mail sending. I have...
2
3428
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 emails, it is not sending them to the email addresses provided. It is accepting the emails just not sending them. I have created a domain and list of...
1
1098
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 match the actual time and date. my problem is that if there is a reminder that matches the actual time and date then the message box will show but...
0
7611
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8051
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7574
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5442
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5162
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3561
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.