So far this is done for account-signup.php, I have many area's to add this to. This replaces the old sendmail() email function, providing you HTML email templates
that let you pull more data or personalize better for users. Plain text is boring.
This sends a HTML welcome email to new user.
Required: PEAR Mail
https://pear.php.net/manual/en/package.mail.mail.factory.php
PEAR mail is excellent, I've been using it since our first 20 members (reaching 20K now) and its never failed once. I recommend it in general over sendmail.
Install:
Here are Linux instructions. I don't use Linux and I don't know it very well, but this will install under "Ubuntu". Install each line individually starting from top:
[color=rgb(44, 130, 201)]#[/color] [color=rgb(226, 80, 65)]sudo apt-get install php-pear[/color]
[color=rgb(44, 130, 201)]#[/color] [color=rgb(226, 80, 65)]sudo pear install mail[/color]
[color=rgb(44, 130, 201)]#[/color] [color=rgb(226, 80, 65)]sudo pear install Net_SMTP[/color]
Now, open account-signup.php and find
Add after
Now open backend/config.php and add
that let you pull more data or personalize better for users. Plain text is boring.
This sends a HTML welcome email to new user.
Required: PEAR Mail
https://pear.php.net/manual/en/package.mail.mail.factory.php
PEAR mail is excellent, I've been using it since our first 20 members (reaching 20K now) and its never failed once. I recommend it in general over sendmail.
Install:
Here are Linux instructions. I don't use Linux and I don't know it very well, but this will install under "Ubuntu". Install each line individually starting from top:
[color=rgb(44, 130, 201)]#[/color] [color=rgb(226, 80, 65)]sudo apt-get install php-pear[/color]
[color=rgb(44, 130, 201)]#[/color] [color=rgb(226, 80, 65)]sudo pear install mail[/color]
[color=rgb(44, 130, 201)]#[/color] [color=rgb(226, 80, 65)]sudo pear install Net_SMTP[/color]
Now, open account-signup.php and find
//send pm to new user
if ($site_config["WELCOMEPMON"]){
$dt = sqlesc(get_date_time());
$msg = sqlesc($site_config["WELCOMEPMMSG"]);
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $id, $dt, $msg, 0)");
}
Add after
if ($site_config["WELCOMEEMAIL"]) {
require_once "Mail.php";
$from = $site_config['SITENAME'] . " <" . $site_config['SITEEMAIL'] . ">";
$subject = "Welcome to " . $site_config['SITENAME'];
$headers = array(
'To' => $email,
'From' => $from,
'Subject' => $subject,
'MIME-Version' => 1,
'Content-type' => 'text/html;charset=iso-8859-1'
);
$smtp = Mail::factory('smtp', array(
'host' => $site_config["mail_smtp_host"],
'auth' => $site_config["mail_smtp_auth"],
'username' => $site_config["mail_smtp_user"],
'password' => $site_config["mail_smtp_pass"]
));
$mail = $smtp->send($email, $headers, $site_config["WELCOMEEMAILBODY"]);
// Log send error
if (PEAR::isError($mail)) {
write_log($mail->getMessage());
return false;
} else {
write_log("Welcome Email successfully sent to " . $email);
}
}
Now open backend/config.php and add
$site_config['WELCOMEEMAIL'] = true;
$site_config['WELCOMEEMAILBODY'] = '
<html>
<head>
<style>body{font-family:arial,sans-serif,helvetica;background-color:rgba(236,236,236,1);margin:0;padding:0}.email-header{background:width:100%;height:56px;margin-bottom:20px}.email-body{box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);background:rgba(255,255,255,1);padding:10 10px 50px 10px;font-size:17px;width:90%;margin:0 auto;text-align:center;overflow:auto}.welcome-msg{font-size:30px;text-align:center;padding:0 20px 20px 0}.welcome-msg2{font-size:17px;text-align:center;padding:0 20px 20 0}.email-body .welcome-msg{padding-top:15px}.email-body a{margin-left:-20px;margin-top:10px}.btn-signin{box-shadow:inset 0 1px 0 0 rgba(242,156,147,1);background:linear-gradient(to bottom,rgba(254,26,0,1) 5%,rgba(206,1,0,1) 100%);background-color:rgba(254,26,0,1);border-radius:6px;border:1px solid rgba(216,53,38,1);display:inline-block;cursor:pointer;color:rgba(255,255,255,1);font-family:Arial;font-size:15px;font-weight:bold;padding:6px 24px;text-decoration:none;text-shadow:0 1px 0 rgba(178,62,53,1)}.btn-signin:hover{background:linear-gradient(to bottom,rgba(206,1,0,1) 5%,rgba(254,26,0,1) 100%);background-color:rgba(206,1,0,1)}.btn-signin:active{position:relative;top:1px}</style>
</head>
<body>
<div class="email-header">
</div>
<div class="welcome-msg">Welcome!</div>
<div class="welcome-msg2">Your account has been activated.</div>
<div class="email-body">
<div class="welcome-msg">Your only movie torrents!</div>
<div class="email-content">
This is my email body. Text will go here.
</div>
<div class="welcome-msg">Sign In</div>
<a href="https://TRACKER.com/signin/" class="btn-signin">Sign In</a>
</div>
</body>
</html>';
