Closed jwren5 closed 9 years ago
Is this a problem in your local dev environment? If so, you need to configure your mail server, which is beyond the scope of UF-related issues. What web server/OS are you developing with?
I have it live on my remote server and am editing code through dream weaver. (I apologize I am still new at much of this)
I set everything up and haven't added anything new. Do I need to for the email?
Thanks.
On Mar 2, 2015, at 5:18 PM, Alex Weissman notifications@github.com wrote:
Is this a problem in your local dev environment? If so, you need to configure your mail server, which is beyond the scope of UF-related issues. What web server/OS are you developing with?
— Reply to this email directly or view it on GitHub.
No problem! Is this your server, or a web hosting company's? There could be a missing module, or they might not have mail configured for whatever reason. Are you getting any errors in your php error log?
It is through Arvixe hosting. I already had to update the PHP version
I have access to configuring mail. Is that all it may be? I tried just using my email and that did not work. Does it have to be associated with that domain?
On Mar 2, 2015, at 5:53 PM, Alex Weissman notifications@github.com wrote:
No problem! Is this your server, or a web hosting company's? There could be a missing module, or they might not have mail configured for whatever reason. Are you getting any errors in your php error log?
— Reply to this email directly or view it on GitHub.
Check your PHP error log for the specific error message. For whatever reason, the built-in PHP mail
function isn't working properly. It's usually an issue with SMTP setup, which means you'd need to contact your hosting service. See this:
https://stackoverflow.com/questions/4733154/unable-to-send-mail-via-php-mail?rq=1
where would i find my PHP error log?
I really appreciate all your help. If it helps, this is a project I am working on for a payment processor that targets non-profits and churches and donates most of its proceeds to helping eliminate poverty around the globe.
Jon Wren
On Mar 2, 2015, at 9:12 PM, Alex Weissman notifications@github.com wrote:
Check your PHP error log for the specific error message. For whatever reason, the built-in PHP mail function isn't working properly. It's usually an issue with SMTP setup, which means you'd need to contact your hosting service. See this: https://stackoverflow.com/questions/4733154/unable-to-send-mail-via-php-mail?rq=1 https://stackoverflow.com/questions/4733154/unable-to-send-mail-via-php-mail?rq=1 — Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/251#issuecomment-76884208.
Hi @jwren5, php error log is something that really depends on your web host's setup. Sometimes, it is simply dumped into your user directory as error_log
, other times they might have a specific location or even an interface that lets you view it.
I don't mind helping you with UserFrosting-related issues, but the issues you are raising are general PHP/webserver-related questions. I know you are new to PHP, but I would kindly ask that in the future you first determine if your issue is specific to UserFrosting, rather than a general PHP/webserver question, before posting here. Many of your questions can be answered by a simple Google search.
I am happy to help you with problems specific to UserFrosting in the future.
I don't know if jwren5 solved his problem, but I'm having the same issue. I'm running my own server (digital ocean) and mail is setup (postfix, dovecot, spamassassin) and works properly outside of UF, but I get the "Fatal error attempting mail" message when trying to register a new user with email verification enabled. Here's the error messages I'm getting in syslog:
Apr 15 17:50:52 panadaxxxx apache2: [15-Apr-2015 17:50:52 America/Los_Angeles] mail() on [/var/www/html/faucet/UserFrosting/models/class.mail.php:82]: To: chrison999@xxxx..ca -- Headers: MIME-Version: 1.0 Content-type: text/plain; charset=iso-8859-1 From: Crazy Canuck Clam Faucet faucet@panadaxxxx.net Apr 15 17:50:52 panadaxxxx postfix/sendmail[8867]: fatal: Recipient addresses must be specified on the command line or via the -t option
(Note: I've obscured the e-mail addresses, but they're correct in syslog)
Hopefully the above will help you (and me) figure out what's wrong.
Thanks!
Chris
Hi Chris,
Have you had problems before with using PHP's mail
function on your server?
Btw, we'll be switching to a modern email library, probably PHPMailer, in the next version. So, if you can't get mail
to work, you might just try replacing it with that library.
Hi, Alex,
Thanks for getting back to me. No, I've not had previous problems with PHP's mail function on the server. However, I'm using PHPMailer for another web app I manage so I'll take a gander at the code and see if I can plug PHPMailer into it.
I'll post back here if I have any problems/questions as I do that.
Thanks!
Chris
No problem, sorry for all the legacy code that's piled up!
I'm "legacy" myself so that's not a problem. ;) Being pretty new to PHP/Javascript programming I am having some challenges figuring out the code, especially following the flow through all the function calls, but I'll get it figured out. If I do run into any major stumbling blocks I'll post back here.
Hi, Alex:
I got diverted for a few days with other matters, but have now worked on getting mail to work. It's basically working (i.e. mails are going out) but I'm getting the following error message when the mail is processed:
I've checked the PHP error logs and don't see any error messages (as I said, the mail does work). I've also looked through the code and that error message is strewn all over the place in db_functions.php and a couple of places in secure_functions.php so it's impossible (for me, at least) to see where the error is coming from.
Here's the edited sendmail() function in my class.mail.php file. Do you see anything that looks messed-up that could be causing the problem?
public function sendMail($email,$subject,$msg = NULL)
{
require '../PHPMailer/PHPMailerAutoload.php';
global $websiteName,$emailAddress,$emailSuccessState;
$mail = new PHPMailer;
$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify SMTP server
$mail->Port = 25; // TCP port to connect to
$mail->From = 'faucet@panadacoin.net';
$mail->FromName = 'Crazy Chris Dogecoin Faucet';
$mail->addAddress($email);
$mail->addReplyTo('chrison@panadacoin.net', 'Crazy Canuck Dogecoin Faucet'); // Name is optional
$mail->addBCC('chrison@panadacoin.net');
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$header .= "From: ". $websiteName . " <" . $emailAddress . ">\r\n";
$mail->header = $header;
$mail->isHTML(false); // Set email format to HTML
$mail->Subject = $subject;
//Check to see if we sending a template email.
if($msg == NULL)
$msg = $this->contents;
$message = $msg;
$message = wordwrap($message, 70);
$mail->Body = $message;
$emailSuccessState = true;
set_error_handler("emailErrorHandler");
$success = $mail->send();
restore_error_handler();
return $success && $emailSuccessState;
}
Thanks for any help you can provide.
Regards,
Chris
So the generic error message you're getting (Oops, look like our server might have goofed) might not be generated in the sendMail
function at all. Is the user actually getting added to the DB afterwards?
Hey, Alex:
Yes, everything is working. The user gets added to the DB, the email (both activation and password reset) get sent, and the account gets activated (or password reset) when the user replies to the e-mail.
I have some time today so I'm going to go through the code and add a line number to each of the generic messages so we can at least pin down which line is failing. Will post that later.
thanks for your help!
Chris
On 15-04-28 09:49 AM, Alex Weissman wrote:
So the generic error message you're getting (Oops, look like our server might have goofed) might not be generated in the |sendMail| function at all. Is the user actually getting added to the DB afterwards?
— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/251#issuecomment-97134839.
Another possibility is that the error is being raised in some other request, but the message isn't getting cleared from the message stream until the confirmation page.
You can check the contents of the message stream at any time by going to api/user_alerts.php
. So, maybe try checking that before hitting the "submit" button.
I went to api/user_alerts.php and got an empty json response ("[]").
Then I created a new user from my phone and got the error message
pointing at userfrosting.js line 457. That's the processJSONResult()
function.
The strange thing is that when I try and create a new user on my laptop I get the "Oops" message but without a pointer to a file/line. I'm 99.99% sure I've found every instance of that message and added the file/line so I'm not sure where that error message without the line is coming from. Again, when I go to api/user_alerts.php before hitting the submit button I get an empty json response ("[]").
Color me confused...
Chris
On 15-04-28 11:33 AM, Alex Weissman wrote:
Another possibility is that the error is being raised in some other request, but the message isn't getting cleared from the message stream until the confirmation page.
You can check the contents of the message stream at any time by going to |api/user_alerts.php|. So, maybe try checking that before hitting the "submit" button.
— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/251#issuecomment-97164243.
So in both cases, is the error being added from userfrosting.js
?
Registering a new user = userfrosting.js line 457 Requesting another validation token = userfrosting.js line 457 Request password reset = userfrosting.js line 457
I haven't been able to reproduce the error message without a line number so I guess I either fixed that or it was a phantom.
Looks like the processJSONResult function is the culprit.
UPDATE: I was just thinking... what does processJSONResult do? I'm not sure (the PHPMailer docs aren't very good, IMHO) but I don't think PHPMailer does anything in JSON. Could that be the problem???
Thanks!
Chris
processJSONResult
was meant to be a catch-all for any possible error that could arise during an AJAX request. For example, if the request returned no response, this function was supposed to generate an alert message rather than silently failing. Or, if the request returned some malformed response, etc.
The idea is that no matter what crazy server-side code someone might have written, the client can at least do something with the response - even if that something is just telling the user that some malformed response was received.
Hmmm... I don't think PHPMail gives any response so maybe that's why processJSONResult is getting triggered? Is there any way to disable or bypass that function for my forms that use PHPMail? As I said, they're working properly so that function isn't really needed.
Thanks!
Chris
What happens if you just echo a response from the server side after PHPMail finishes?
echo json_encode(["errors" => 0, "successes" => 1]);
Alex:
That didn't do anything, but I found the problem... it was this line in models/class.mail.php:
$mail->SMTPDebug = 3; // Enable verbose debug output
Apparently UF was interpreting smtp debug messages (which were reporting the success of the send) as errors which tripped that alert. I have removed that line from class.mail.php and now everything is fine.
Thanks SOOOOOO much for your help/suggestions. I apologize for taking up a lot of your time for such a silly error on my part.
Regards,
Chris
No problem, this is all useful to know for the future. So, PHPMail just outputs debug messages to the response? (Instead of the error log?)
Yeah, all good info for the future but, still, I feel a bit silly that the problem was staring me in the face all the time while I ran around in circles hunting for it somewhere else. Oh, well! ;)
Anyway, it appears that PHP outputs debug messages to the browser (via
the response?) or UF is grabbing the PHPMail debug messages before they
can be posted to the PHP error logs. I sure can't find any PHPMail
errors in the collection of PHP error logs I have (and I have a lot!
<grin!>).
On 15-05-04 07:09 AM, Alex Weissman wrote:
No problem, this is all useful to know for the future. So, PHPMail just outputs debug messages to the response? (Instead of the error log?)
— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/251#issuecomment-98720590.
Yep, anything output to the browser is a response (unless of course, it's something the browser itself is generating, e.g. through Javascript, etc).
There is probably some configuration setting in PHPMail that decides where to put error messages...
Hey Alex:
I did a quick browse through the PHPMailer docs (which was quick because there isn't much there), and all I could find is an optional callback function that echoes what's happening to the browser but, with a bit of work, could be modified to post to a database, create a cvs file, or do anything else you'd want to do so long as you can code it.
Other than that, it appears that PHPMailer echoes everything to the browser. My "solution" is to turn-off all debugging messages and let UF handle any errors.
Again, thanks for your help!
Chris
On 15-05-04 06:02 PM, Alex Weissman wrote:
Yep, anything output to the browser is a response (unless of course, it's something the browser itself is generating, e.g. through Javascript, etc).
There is probably some configuration setting in PHPMail that decides where to put error messages...
— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/251#issuecomment-98896141.
Haha alright, sounds good. Glad everything worked out!
I installed successfully everything and every time i attempt to register a new login, this error displays "Fatal error attempting mail, contact your server administrator"
Is this a problem with the site email? how do I get that all set up? I can't seem to find documentation any where.