I tried using the search for hours to find a complete solution for this but i couldn't, nd that's y i'm making this post.
I have the latest ravennuke installed and running fine, the only thing is it can't send activation emails to any address other than the once on my domain itself.
I contacted the hosting company and they said they've disabled php Mail() on their servers so i have to use smtp, and gave me a link to some code. I have no idea how to use that code, no idea which files to modify. So if u guys can tell me which files i have to modify it would be of great help.
Joined: Aug 27, 2002 Posts: 16976 Location: Kansas
Posted:
Fri May 19, 2006 10:51 pm
nivz, I have "cleaned up" your post for easier reference
Create a file called authSendEmail.php and place the Function Code block in the file and store it in the includes folder. Now, where ever you have the php mail() function, add include_once('includes/authSendEmail.php'); to any script that uses the mail() function. Then use the Common Code to set up (replace your mail() code. So, in essence, the function authSendEmail replaces every occurrence of mail() and the Common Code is the setup code to call it. You could change the Common Code block to read
I think i got it, I'll give it a shot and see what happens.. Thanks so much for the info!!
-edit-
Where can i find the code to send the activation emails? that's all i want to modify. I'm a complete noob@php so I ruined my site a couple of times and had to re install everything. (so i'm kinda scared to edit anything )
Hi guys, I tried this and it's not working.. can someone tell me whether i'm doing anything wrong? or is there any other way to get around this? please consider that my php understaning is quite low so please be kind enough to explain in a lil detail..
include_once('includes/authSendEmail.php');
authSendEmail($from, "MY NAME" , $user_email, $user_email, $subject, $message);
to this
Code:
authSendEmail($from, "MY NAME" , $user_email, $user_email, $subject, $message);
Now, as to your problem in getting it to work ....
I haven't tested your Host's code. but let's assume, for the moment, that it does work. In comparing the 2 calls
authSendEmail($from, "MY NAME" , $user_email, $user_email, $subject, $message);
with
mail($user_email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion());
Let's assume that under the PHP Mail() function you had this:
$user_email = "raven@ravenphpscripts.com";
$subject = "Test Email";
$message = "This is a test mail using the PHP Mail() function.";
$from = "you@yourdomain.com"; //Needs a valid email address
mail($user_email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion()); should work.
Now, mapping that to your Host's new function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message); it should look like this:
//new function
$to = "raven@ravenphpscripts.com";
$nameto = "Raven";
$from = "you@yourdomain.com"; //Needs a valid email address
$namefrom = "NIVZ";
$subject = "Test Email";
$message = "This is a test mail using the Host authSendEmail function.";
Technically speaking, that should work. Make sure you comment out the mail() function in your code.
You can test this outside of Your_Account module by doing this. Make sure that you have correctly filled in the
//SMTP + SERVER DETAILS
/* * * * CONFIGURATION START * * * */
$smtpServer = "mail.server.com";
$port = "25";
$timeout = "30";
$username = "smtpusername";
$password = "smtppassword";
$localhost = "localhost";
$newLine = "\r\n";
/* * * * CONFIGURATION END * * * * */
Code:
<?
//new function
$to = "raven@ravenphpscripts.com";
$nameto = "Raven";
$from = "you@yourdomain.com"; //Needs a valid email address
$namefrom = "NIVZ";
$subject = "Test Email";
$message = "This is a test mail using the Host authSendEmail function.";
I did fill the smtp bits correctly, (same settings on the forum works fine). only thing I think I've done wrong is putting
include_once('includes/authSendEmail.php');
b4 every call to authSendEmail(). If i only have to use this line once in the code, where should i put it? in the beginning of the script? or just use it before the fist call to authSendEmail() and just use the function from there after?
I replaced the mail function in the code with authSendMail().
Hi Raven, Still no luck.. I tried to send a test message using the authSendEmail() on a test script and it first said the include file is not there. Then i moved it to the same folder as the script was and then didn't get any error messages.
but the email has not been sent.. i think it's the code my host gave me, doesnt seem to be working...
I'll contact my hosting provider again anyway and see how it goes.. Thanks a billion times for the help raven..
ok, so I've tried this test, what I did was the include the entire thing into one file, and I actually get a responce from my provider, however it still fails, here is what I get :
Only registered users can see links on this board! Get registered or login to the forums!
" }
so when going to the
Only registered users can see links on this board! Get registered or login to the forums!
address, it's telling me that "Bare LFs in SMTP" is the problem. I've looked at the script, and I can't see where this problem is coming from.
btw, the above output is exactly as it is shown. The outputs don't show any CR. How can I add that to the code to make it easier to read?
Thanks in advance,
Spyrule.
p.s. - btw, This is the closest I have come so far as to figure out wtf has been causing me to not be able to send via my provider. So A HUGE pre-thank you !!!!
I myself and not much of a php coder, but I do understand the principles of code, and general syntax. Also, everything else works nearly perfectly on my server, This is my last hurdle.
so here is the final update for those people, whose email servers require CR before LS (which is smtp standard I think). Minor fix to Raven's code.
BEFORE:
Code:
// (near the bottom, right after the 3 headers lines)
fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n");
AFTER:
Code:
// (near the bottom, right after the 3 headers lines)
fputs($smtpConnect, "To: $to\r\nFrom: $from\r\nSubject: $subject\r\n$headers\r\n\r\n$message\r\n.\r\n");
Basically, I think raven forgot the CR ( \ r ) before each new line ( \ n ).
I bolded them to indicate as such. Plus SMTP protocol requires the message to end in CRLF.CRLF . so thats why the \ r \ n . \ r \ n at the end of the last fputs command.
Anyway, it's 1:30am and I gotta work @ 6... so g'night. be back tommorow with a final update if it works throughout nuke.
Spyrule
P.s. - I will sleep with a smile on my face. Cheers guys.
so I got the initial test script to work... but now I cannot figure out how to IMPLEMENT it into the registration process. I'm pretty sure its in the /Your_Account/index.php
I've added an include_once("includes/AuthSendEmail.php");
just under the initial comments section in the index file,
Joined: Aug 29, 2004 Posts: 9070 Location: Arizona
Posted:
Tue Jun 13, 2006 6:25 am
Try changing your $from variable to what you see in the BEFORE code and see if that works, because other than that, it sure looks like it would work.
Also, I am sure you tested it. If it does not work, please be specific with how it did not work, any output produced, error messages, etc. so that we can help debug better.
Joined: Aug 29, 2004 Posts: 9070 Location: Arizona
Posted:
Tue Jun 13, 2006 9:44 pm
Within your config.php file there is a $display_errors = 0 (by default) -- in some installations it could say "FALSE". Set this to a 1. If you have access to some sort of host provided control panel (almost all do), you should also have access to some tool there to look at your Apache error log, which might catch different kinds of errors.
You may have the use "echo" to check the values of your variables being passed into the send function just to make sure they are getting valued / passed as you would expect them to (based on your prior testing of this function outside of nuke).
Unfortunetly, That is part of my ghost log problem... I run my own Windows 2003 server with IIS 6, php 5.0.4, and mySQL 4.1 . I always had problem with apache in windows, so I found IIS to be fairly simple once I started using it.
so after enabling error generation, I found that I had called the include file twice.
removed the second one, and that error went away.
Now I essentially get NO error, but I still don't get the email.... argh!.
This is driving me bonker. Anybody know of a way to modify ravens above script so that it dumps the responce to either the screen or a file? a file would be nice and clean, and would help me figure stuff out, without having to mess with visual output.
I am sadly not a very knowledgable php coder... I can read it, understand it, but I have NO IDEA where to start to make the additions to the code to do that. ANY help is greatly apreciated.
btw, I'm sorry for being a "leach" for info... I usually try and do my research and do my own work, but this one seriously has me stumped....
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum