happypete Posted April 19, 2012 Share Posted April 19, 2012 My server doest allow the 'mail' function so I'm trying to add the PHPMailer to the following code. Ive used it before, but just cant work out how to add it to this script.... I've added the PHPmailer class require_once('phpmailer/class.phpmailer.php'); include("phpmailer/class.smtp.php"); The bit I'm stuck on is how to change the mail function to use PHPMailer instead /* Is both Username and Password set? */ if(!isset($error)) { $return_form = 0; /* Final Format */ $password = $this->genHash($this->genSalt(), $password); /* Send the user a welcome E-Mail */ if($this->email_welcome == true) { /* Send the user an E-Mail */ /* Can we send a user an E-Mail? */ if(function_exists('mail') && $this->email_master != null) { $subject = "Thank you for creating an account, " . $username; $body_content = "Hi " . $username . ",<br />Thanks for signing-up!<br /><br /><i>-Admin</i>"; /* E-Mail body */ $body = '<html lang="en"><body style="margin: 0; padding: 0; width: 100% !important;" bgcolor="#eeeeee"><table bgcolor="#eeeeee" cellpadding="0" cellspacing="0" border="0" align="center" width="100%" topmargin="0"><tr><td align="center" style="margin: 0; padding: 0;"><table cellpadding="0" cellspacing="0" border="0" align="center" width="100%" style="padding: 20px 0;"><tr><td width="600" style="font-size: 0px;"> </td></tr></table><table width="600" cellspacing="0" cellpadding="0" border="0" align="center" class="header" style="border-bottom: 1px solid #eeeeee; font-family: Helvetica, Arial, sans-serif; background:#ffffff;"><tbody><tr><td width="20" style="font-size: 0px;"> </td><td width="580" align="left" style="padding: 5px 0 10px;"><h1 style="color: #444444; font: bold 32px Helvetica, Arial, sans-serif; margin: 0; padding: 0; line-height: 40px; border: none;">Your accound has been created</h1></td></tr></tbody></table></td></tr><tr><td align="center" style="margin: 0; padding: 0;"><table align="center" border="0" style="background-color:#ffffff;" width="600" height="100" cellpadding="3" cellspacing="3"><tr><td style="color: #222222; font: normal 16px Helvetica, Arial, sans-serif; margin: 0; padding: 10px; line-height: 18px;">' . $body_content . '</td></tr></table></td></tr><tr><td align="center" style="margin: 0; padding: 0;"><table cellpadding="0" cellspacing="0" border="0" align="center" width="100%" style="padding: 20px 0;"><tr><td width="600" style="font-size: 0px;"> </td></tr></table></td></tr></table></body></html>'; /* Headers */ $headers = "From: " . strip_tags($this->email_master) . "\r\n"; $headers .= "Reply-To: ". strip_tags($this->email_master) . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; /* Send it */ mail($email, $subject, $body, $headers); } } trying to change the 'mail' function and use this: $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "mail.mydomain.com"; // SMTP server $mail->SMTPDebug = 1; // 1 = errors and messages,2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "mail.mydomain.com"; // sets the SMTP server $mail->Port = 25; // set the SMTP port for the GMAIL server $mail->Username = "user@mydomain.com"; // SMTP account username $mail->Password = "mypassword"; // SMTP account password $mail->CharSet = 'UTF-8'; // so it interprets foreign characters $mail->SetFrom = 'email@yahoo.com'; $mail->AddReplyTo = 'email@yahoo.com'; $mail->Subject($subject); $mail->MsgHTML($body); $mail->AddAddress($email); //($email_master); $mail->Send(); So I need to change these lines..?? /* Can we send a user an E-Mail? */ if(function_exists('mail') && $this->email_master != null) & /* Send it */ if(mail($email, $subject, $body, $headers)) I tried this but it didn't work: /* Is both Username and Password set? */ if(!isset($error)) { $return_form = 0; /* Final Format */ $password = $this->genHash($this->genSalt(), $password); /* Send the user a welcome E-Mail */ if($this->email_welcome == true) { /* Send the user an E-Mail */ /* Can we send a user an E-Mail? */ if($this->email_master != null) { $subject = "Thank you for creating an account, " . $username; $body_content = "Hi " . $username . ",<br />Thanks for signing-up!<br /><br /><i>-Admin</i>"; /* E-Mail body */ $body = '<html lang="en"><body style="margin: 0; padding: 0; width: 100% !important;" bgcolor="#eeeeee"><table bgcolor="#eeeeee" cellpadding="0" cellspacing="0" border="0" align="center" width="100%" topmargin="0"><tr><td align="center" style="margin: 0; padding: 0;"><table cellpadding="0" cellspacing="0" border="0" align="center" width="100%" style="padding: 20px 0;"><tr><td width="600" style="font-size: 0px;"> </td></tr></table><table width="600" cellspacing="0" cellpadding="0" border="0" align="center" class="header" style="border-bottom: 1px solid #eeeeee; font-family: Helvetica, Arial, sans-serif; background:#ffffff;"><tbody><tr><td width="20" style="font-size: 0px;"> </td><td width="580" align="left" style="padding: 5px 0 10px;"><h1 style="color: #444444; font: bold 32px Helvetica, Arial, sans-serif; margin: 0; padding: 0; line-height: 40px; border: none;">Your accound has been created</h1></td></tr></tbody></table></td></tr><tr><td align="center" style="margin: 0; padding: 0;"><table align="center" border="0" style="background-color:#ffffff;" width="600" height="100" cellpadding="3" cellspacing="3"><tr><td style="color: #222222; font: normal 16px Helvetica, Arial, sans-serif; margin: 0; padding: 10px; line-height: 18px;">' . $body_content . '</td></tr></table></td></tr><tr><td align="center" style="margin: 0; padding: 0;"><table cellpadding="0" cellspacing="0" border="0" align="center" width="100%" style="padding: 20px 0;"><tr><td width="600" style="font-size: 0px;"> </td></tr></table></td></tr></table></body></html>'; /* Headers */ $headers = "From: " . strip_tags($this->email_master) . "\r\n"; $headers .= "Reply-To: ". strip_tags($this->email_master) . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; /* Send it */ $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "mail.mydomain.com"; // SMTP server $mail->SMTPDebug = 1; // 1 = errors and messages,2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "mail.mydomain.com"; // sets the SMTP server $mail->Port = 25; // set the SMTP port for the GMAIL server $mail->Username = "user@mydomain.com"; // SMTP account username $mail->Password = "mypassword"; // SMTP account password $mail->CharSet = 'UTF-8'; // so it interprets foreign characters $mail->SetFrom = 'email@yahoo.com'; $mail->AddReplyTo = 'email@yahoo.com'; $mail->Subject($subject); $mail->MsgHTML($body); $mail->AddAddress($email); //($email_master); $mail->Send(); } } Quote Link to comment https://forums.phpfreaks.com/topic/261223-implementing-phpmailer/ Share on other sites More sharing options...
Muddy_Funster Posted April 19, 2012 Share Posted April 19, 2012 and what does "it doesn't work" actualy translate to? Quote Link to comment https://forums.phpfreaks.com/topic/261223-implementing-phpmailer/#findComment-1338671 Share on other sites More sharing options...
happypete Posted April 19, 2012 Author Share Posted April 19, 2012 I just get a white page. and no email is sent out Quote Link to comment https://forums.phpfreaks.com/topic/261223-implementing-phpmailer/#findComment-1338752 Share on other sites More sharing options...
Muddy_Funster Posted April 25, 2012 Share Posted April 25, 2012 do you have error reporting set to all? Quote Link to comment https://forums.phpfreaks.com/topic/261223-implementing-phpmailer/#findComment-1340433 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.