Added : PHPmailer for proper emails
This commit is contained in:
parent
7819a5ba67
commit
0b763ae399
6 changed files with 133 additions and 54 deletions
|
@ -1,17 +1,9 @@
|
|||
INSERT INTO `clipbucket_svn`.`cb_config` (
|
||||
`configid` ,
|
||||
`name` ,
|
||||
`value`
|
||||
)
|
||||
VALUES (
|
||||
NULL , 'use_ffmpeg_vf', 'no'
|
||||
);
|
||||
|
||||
INSERT INTO `clipbucket_svn`.`cb_config` (
|
||||
`configid` ,
|
||||
`name` ,
|
||||
`value`
|
||||
)
|
||||
VALUES (
|
||||
NULL , 'use_crons', 'no'
|
||||
);
|
||||
INSERT INTO cb_config (name,value) VALUES
|
||||
('use_ffmpeg_vf','no'),
|
||||
('use_crons','no'),
|
||||
('mail_type','mail'),
|
||||
('smtp_host','mail.myserver.com'),
|
||||
('smtp_user','user@myserver.com'),
|
||||
('smtp_pass','password'),
|
||||
('smtp_auth','yes'),
|
||||
('smtp_port','26');
|
|
@ -26,6 +26,30 @@ if(isset($_POST['update']))
|
|||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['update_settings'])){
|
||||
$configs = $Cbucket->configs;
|
||||
|
||||
$rows = array(
|
||||
'mail_type',
|
||||
'smtp_host',
|
||||
'smtp_user',
|
||||
'smtp_pass',
|
||||
'smtp_auth',
|
||||
'smtp_port'
|
||||
);
|
||||
|
||||
|
||||
foreach($rows as $field)
|
||||
{
|
||||
$value = ($_POST[$field]);
|
||||
$myquery->Set_Website_Details($field,$value);
|
||||
}
|
||||
e("Email Settings Have Been Updated",'m');
|
||||
|
||||
}
|
||||
|
||||
$row = $myquery->Get_Website_Details();
|
||||
Assign('row',$row);
|
||||
|
||||
subtitle("Email Settings");
|
||||
template_files('email_settings.html');
|
||||
|
|
|
@ -1,5 +1,65 @@
|
|||
<h2>Email Settings</h2>
|
||||
<form action="" method="post" enctype="multipart/form-data" name="player_settings">
|
||||
<fieldset class="fieldset" style="border:none">
|
||||
<table width="100%" border="0" cellpadding="2" cellspacing="0" class="block">
|
||||
<tr>
|
||||
<td width="301" valign="top"><strong><label for="mail_type">Mailer</label></strong><br />
|
||||
Select Mailer Type php Mail() or SMTP</label></td>
|
||||
<td width="813" valign="top">
|
||||
<select name="mail_type" id="mail_type">
|
||||
<option value="mail" {if $row.mail_type=='mail'} selected="selected"{/if}>PHP mail()</option>
|
||||
<option value="smtp" {if $row.mail_type=='smtp'} selected="selected"{/if}>smtp</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><strong><label for="smtp_host">SMTP Host</label><br />
|
||||
</strong>If using smtp, please enter its server</td>
|
||||
<td valign="top">
|
||||
<input type="text" name="smtp_host" id="smtp_host" value="{$row.smtp_host}" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><strong><label for="smtp_port">SMTP Port</label></strong><br />
|
||||
if using smtp, Set SMTP server port</td>
|
||||
<td valign="top">
|
||||
<input type="text" name="smtp_port" id="smtp_port" value="{$row.smtp_port}" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><strong><label for="smtp_user">SMTP Username</label></strong><br />
|
||||
if using smtp, please enter SMTP username</td>
|
||||
<td valign="top">
|
||||
<input type="text" name="smtp_user" id="smtp_user" value="{$row.smtp_user}" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><strong><label for="smtp_pass">SMTP Password</label></strong><br />
|
||||
Enter SMTP password</td>
|
||||
<td valign="top">
|
||||
<input type="password" name="smtp_pass" id="smtp_pass" value="{$row.smtp_pass}" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><strong>SMTP Auth</strong><br />
|
||||
Enable SMTP Authentication
|
||||
</td>
|
||||
<td valign="top"><select name="smtp_auth" id="smtp_auth">
|
||||
<option value="yes" {if $row.smtp_auth=='yes'} selected="selected"{/if}>yes</option>
|
||||
<option value="no" {if $row.smtp_auth=='no'} selected="selected"{/if}>no</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"> </td>
|
||||
<td valign="top"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"> </td>
|
||||
<td valign="top"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<div align="left"><input type="submit" class="button" value="Update" name="update_settings" /></div>
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
<div style="height:10px"></div>
|
||||
<h2>Email Templates Settings</h2>
|
||||
|
||||
<div style="height:10px"></div>
|
||||
|
||||
<div style="padding-right:10px">
|
||||
|
@ -16,7 +76,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="100%" border="0" cellpadding="2" cellspacing="0" class="block" id="template-{$template.email_template_id}">
|
||||
<table width="100%" border="0" cellpadding="2" cellspacing="0" class="block" id="template-{$template.email_template_id}" style="display:none">
|
||||
<tr>
|
||||
<td width="114" align="right" valign="top"><span class="td_body">Email Subject</span></td>
|
||||
<td valign="top" style="padding-left:10px"><input type="hidden" value="{$template.email_template_id}" name="template_id[]"/><input name="subject[]" type="text" id="subject[]" value="{$template.email_template_subject|form_val}" size="80" /></td>
|
||||
|
|
|
@ -43,7 +43,7 @@ if(isset($_POST['contact']))
|
|||
$msg = nl2br($cbemail->replace($tpl['email_template'],$var));
|
||||
|
||||
//Now Finally Sending Email
|
||||
cbmail(array('to'=>WEBSITE_EMAIL,'from'=>$email,'subject'=>$subj,'content'=>$msg));
|
||||
if(cbmail(array('to'=>SUPPORT_EMAIL,'from'=>$email,'subject'=>$subj,'content'=>$msg)))
|
||||
e(lang("email_send_confirm"),"m");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
class CBEmail
|
||||
{
|
||||
|
||||
var $smtp = false;
|
||||
var $db_tpl = 'email_templates';
|
||||
|
||||
function cbemail()
|
||||
|
@ -126,6 +126,11 @@ class CBEmail
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to send email via smtp
|
||||
*/
|
||||
//functio cbemail_smtp($to,$from,$subj,$message,
|
||||
}
|
||||
|
||||
?>
|
|
@ -221,34 +221,11 @@
|
|||
$subject = $array['subject'];
|
||||
$to = $array['to'];
|
||||
$from = $array['from'];
|
||||
$to_name = $array['to_name'];
|
||||
$from_name = $array['from_name'];
|
||||
|
||||
if($array['nl2br'])
|
||||
$content = nl2br($content);
|
||||
|
||||
//Setting Boundary
|
||||
$mime_boundary = "----ClipBucket Emailer----".md5(time());
|
||||
|
||||
$headers = "From: ".$from." \r\n";
|
||||
$headers .= "Content-Type: text/html; charset=UTF-8\n";
|
||||
$headers .= "Content-Transfer-Encoding: 7bit \r\n";
|
||||
$headers .= "MIME-Version: 1.0\r\n";
|
||||
//Checking if has CC
|
||||
if($array['cc'])
|
||||
$headers .= "cc: ".$array['cc']." \r\n";
|
||||
//Checking if has BCC
|
||||
if($array['bcc'])
|
||||
$headers .= "Bcc: ".$array['bcc']." \r\n";
|
||||
//Setting Mailer
|
||||
$headers .= "X-Mailer: ClipBucket v2 \r\n";
|
||||
|
||||
//Starting Message
|
||||
if($array['user_boundary'])
|
||||
{
|
||||
$message = "--$mime_boundary--\n";
|
||||
$message .= "Content-Type: text/html; charset=UTF-8\n";
|
||||
$message .= "Content-Transfer-Encoding: 8bit\n\n";
|
||||
}
|
||||
|
||||
|
||||
# CHecking Content
|
||||
if(preg_match('/<html>/',$content,$matches))
|
||||
|
@ -259,18 +236,39 @@
|
|||
}
|
||||
}
|
||||
$message .= $content;
|
||||
if($array['user_boundary'])
|
||||
|
||||
//ClipBucket uses PHPMailer for sending emails
|
||||
include("classes/phpmailer/class.phpmailer.php");
|
||||
include("classes/phpmailer/class.smtp.php");
|
||||
|
||||
$mail = new PHPMailer(); // defaults to using php "mail()"
|
||||
|
||||
$mail_type = config('mail_type');
|
||||
|
||||
//---Setting SMTP ---
|
||||
if($mail_type=='smtp')
|
||||
{
|
||||
//Ending Message
|
||||
$message .= "--$mime_boundary--\n";
|
||||
$mail->IsSMTP(); // telling the class to use SMTP
|
||||
$mail->Host = config('smtp_host'); // SMTP server
|
||||
if(config('smtp_auth')=='yes')
|
||||
$mail->SMTPAuth = true; // enable SMTP authentication
|
||||
$mail->Port = config('smtp_port'); // set the SMTP port for the GMAIL server
|
||||
$mail->Username = config('smtp_user'); // SMTP account username
|
||||
$mail->Password = config('smtp_pass'); // SMTP account password
|
||||
}
|
||||
|
||||
$email = mail ($to,$subject,$message,$headers);
|
||||
if( $email == true ){
|
||||
//--- Ending Smtp Settings
|
||||
|
||||
$mail->SetFrom($from, $from_name);
|
||||
$mail->AddAddress($to, $to_name);
|
||||
$mail->Subject = $subject;
|
||||
$mail->MsgHTML($message);
|
||||
|
||||
if(!$mail->Send())
|
||||
{
|
||||
e("Mailer Error: " . $mail->ErrorInfo);
|
||||
return false;
|
||||
}else
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function send_email($from,$to,$subj,$message)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue