Loading...
 
Skip to main content

Architecture / Installation


Re: Configure for mail relay

posts: 49 Canada

As far as I can tell from php.net and mail() function it cannot use SMTP relay that requires authentication. I googled around a bit and ended up hacking the file tiki-register.php to use sourceforge's PHPmailer class (class.phpmailer.php and class.smtp.php).

I need to clean up a bit more but it looks something like this:

excerpt for tiki-regsiter.php:

Image
Copy to clipboard
if($validateUsers == 'y' and $email_valid != 'no') { //$apass = addslashes(substr(md5($tikilib->genPass()),0,25)); $apass = addslashes(md5($tikilib->genPass())); $foo = parse_url($_SERVER["REQUEST_URI"]); $foo1=str_replace("tiki-register","tiki-login_validate",$foo["path"]); $machine =httpPrefix().$foo1; $userlib->add_user($_REQUEST["name"],$apass,$_REQUEST["email"],$_REQUEST["pass"]); $emails = $notificationlib->get_mail_events('user_registers','*'); foreach($emails as $email) { $smarty->assign('mail_user',$_REQUEST["name"]); $smarty->assign('mail_date',date("U")); $smarty->assign('mail_site',$_SERVER["SERVER_NAME"]); $mail_data = $smarty->fetch('mail/new_user_notification.tpl'); //mail($email, tra('New user registration'),$mail_data,"From: $sender_email\r\nContent-type: text/plain;charset=utf-8\r\n"); } // Send the mail $smarty->assign('msg',tra('You will receive an email with information to login for the first time into this site')); $smarty->assign('mail_machine',$machine); $smarty->assign('mail_site',$_SERVER["SERVER_NAME"]); $smarty->assign('mail_user',$_REQUEST["name"]); $smarty->assign('mail_apass',$apass); $mail_data = $smarty->fetch('mail/user_validation_mail.tpl'); // Hack in PHPmailer function so that we can support SMTP Authentication require("class.phpmailer.php"); require("includes/config.inc"); $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = OV_SMTPhost; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = OV_SMTPuser; // SMTP username $mail->Password = OV_SMTPpassword; // SMTP password $mail->From = OV_SMTPfrom; $mail->FromName = OV_SMTPfromname; $mail->AddAddress ($_REQUEST["email"]); $mail->AddReplyTo (OV_SMTPaddreplyto); $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = OV_SMTPsubject; $mail->Body = $mail_data; if(!$mail->Send()) { echo "Message was not sent "; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; // end of PHPmailer Hack //mail($_REQUEST["email"], tra('Your Tiki information registration'),$mail_data,"From: $sender_email\r\nContent-type: text/plain;charset=utf-8\r\n"); $smarty->assign('showmsg','y'); } elseif ($email_valid != 'no') { $userlib->add_user($_REQUEST["name"],$_REQUEST["pass"],$_REQUEST["email"],''); $smarty->assign('msg',tra("Thank you for you registration. You may log in now.")); $smarty->assign('showmsg','y'); } }


where the OV_SMTP constants are defines for my ISP's SMTP requirements that i have in the includes/config.inc file.

Seems to work fine now.

posts: 2881 United Kingdom


Now you need to build that into a library, and use it at all the other mail(); points in Tiki 😉

Damian


posts: 1

> As far as I can tell from php.net and mail() function it cannot use SMTP relay that requires authentication. I googled around a bit and ended up hacking the file tiki-register.php to use sourceforge's PHPmailer class (class.phpmailer.php and class.smtp.php).
>
> I need to clean up a bit more but it looks something like this:



Thats for posting that, my mail server is setup for requiring authentication. I do have a problem, followed what you did but get an error and not sure what I need to change where:

26-Jun-2004 16:39:41 PHP Fatal error: Cannot redeclare class smtp in c:\www\php-4.3.6\PEAR\class.smtp.php on line 25

Any tips?


posts: 49 Canada

It kind of looks like you have a PEAR class.smtp.php file being included somewhere earlier which is defining the class "smtp". This will conflict with the smtp class declaration that gets done in the class file that i suggested was required for this app.

I checked my PEAR folder and i have hardly anything in it and no mail files; do you have any idea where you include this PEAR class file and why? Perhaps it is done through the php.ini ?

Peter...


posts: 49 Canada

People actually read my post.. cool.. hope it helped someone...

As for building library; i have been a Tiki user for all of 1 week now ... and only been using PHP for a while... so not quite sure how to go about this; or, if i did, how to submit it for everyone.

I did, after doing this, realize that there are other points in the Tiki system that use mail() that would also need to get changed; but so far i am not suing any of them. I do suspect my site (www.ottawavolleyball.com) will eventually use newsletters at which time i will try to do this all the "right" way.

I have (in the past week) hacked a few differnt features to get what i wanted; but mostly pretty simple things. But i need a ocuple "big" features (user directory for example) that i don't seem to find anywhere here - so i suspect i will become more familiar with Tiki pretty quickly.

cheers,
Peter...