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.'));
} 4 3012
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
==================
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!
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
==================
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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,...
|
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...
|
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...
|
by: Eduardo Rosa |
last post by:
Somebody knows how I queue email using .Net?
thanks a lot
|
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.
...
|
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...
|
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...
|
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...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
| |