Last active
December 25, 2015 05:59
-
-
Save gubi/6928499 to your computer and use it in GitHub Desktop.
If you want to remove all subscriber of a Mailing List and re-subscribe them with a new email address, these scripts help you to massive inform them.
My provider (OVH) do not allow to automate this operation, so follow these steps:
1. Create a new table "site_users" in a database, with "name", "last_name", "email", "email2" and "user_type" colum…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[database] | |
host = "YOUR DATABASE HOST" | |
name = "YOUR DATABASE USERNAME" | |
username = "YOUR DATABASE USERNAME" | |
password = "YOUR DATABASE PASSWORD" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This function connect to System database | |
* | |
* PHP versions 4 and 5 | |
* | |
* LICENSE: This source file is subject to version 3.0 of the PHP license | |
* that is available through the world-wide-web at the following URI: | |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of | |
* the PHP License and are unable to obtain it through the web, please | |
* send a note to [email protected] so we can mail you a copy immediately. | |
* | |
* @category SystemScript | |
* @author Alessandro Gubitosi <[email protected]> | |
* @link http://4cento.it/ | |
* | |
*/ | |
function db_connect($table = ""){ | |
$config = parse_ini_file(".config.conf", 1); | |
$pdo = new PDO("mysql:host=" . $config["database"]["host"] . ";dbname=" . $config["database"]["name"], $config["database"]["username"], $config["database"]["password"], array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); | |
return $pdo; | |
} | |
$pdo = db_connect(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header("Content-type: text/plain; charset=utf-8"); | |
require_once(".mysql_connect.inc.php"); | |
// Requires PEAR Mail | |
require_once("Mail.php"); | |
/* Configurations */ | |
// BOT and Association data | |
$robot_name = "Jervis"; | |
$assoc_name = "400"; | |
$system_mail = "[email protected]"; | |
$assoc_site = "www.4cento.it"; | |
$support_mail = "[email protected]"; | |
$reset_interface_domain = "http://password.mail.4cento.it"; | |
$mail_domain = "http://mail.4cento.it"; | |
$main_admin_name = "Alessandro Gubitosi"; | |
$right_mail_dns = "@4cento.it"; | |
// Mail data | |
$pop_host = "ssl0.ovh.net"; | |
$pop_sec_type = "SSL/TLS"; | |
$pop_port = 995; | |
$pop_auth_type = "Sì, con login semplice"; | |
$smtp_host = "ssl0.ovh.net"; | |
$smtp_sec_type = "SSL/TLS"; | |
$smtp_port = 465: | |
$smtp_auth_type = "Sì, con login semplice"; | |
$email_text = <<<Email_text | |
Ciao {NAME}, | |
sono $robot_name e ho appena creato il tuo nuovo indirizzo e-mail: {NEW_EMAIL} | |
Per questioni di sicurezza sono stato istruito a cancellare il tuo attuale indirizzo e-mail ({OLD_EMAIL}) da ogni Mailing List dell'Associazione, e ad iscriverti con quello appena creato. | |
Ho creato anche una password per il tuo account che conosci solo tu: questo la rende un po' sicura, ma è preferibile che tu la reimposti per ricordarla meglio in futuro. | |
Non ti resta che accedere a $mail_domain con i nuovi dati, oppure creare un nuovo account al tuo editor di posta preferito con i parametri a seguire: | |
> * Nome utente/Username: {NEW_EMAIL} | |
> * Password: {EMAIL_PASS} | |
POSTA IN ENTRATA (POP) | |
-------------------------------- | |
> * Indirizzo POP: $pop_host | |
> * Sicurezza: $pop_sec_type | |
> * Porta POP: $pop_port | |
> * Autenticazione: $pop_auth_type | |
POSTA IN USCITA (SMTP) | |
-------------------------------- | |
> * Indirizzo SMTP: $smtp_host | |
> * Sicurezza: $smtp_sec_type | |
> * Porta POP: $smtp_port | |
> * Autenticazione: $smtp_auth_type | |
Il processo di configurazione generalmente è automatizzato e non dovrebbe risultare difficile. | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
*ISTRUZIONI PER CAMBIARE LA PROPRIA PASSWORD* | |
Vai su $reset_interface_domain e inserisci i dati attuali (indicati in questa mail), quindi clicca su "Accedi" e inserisci la nuova password 2 volte. | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Se hai comunque bisogno di aiuto, contatta pure i moderatori delle Mailing List ({MODERATOR_NAMES}), oppure invia una mail a $support_mail. | |
{MODERATOR_MESSAGE} | |
Un saluto | |
--=20 | |
$robot_name $assoc_name | |
$system_mail | |
$assoc_site | |
Email_text; | |
$db_users = $pdo->query("select * from `site_users` where `email2` not like '%" . $right_mail_dns . "'"); | |
if($db_users->rowCount() > 0) { | |
$i = -1; | |
while($dato_users = $db_users->fetch()) { | |
$i++; | |
$from = $robot_name . ' ' . $assoc_name . '<' . $system_mail . '>'; | |
$to = $dato_users["name"] . " " . $dato_users["last_name"] . ' <' . $dato_users["email2"] . '>'; | |
$subject = "[Importante] Reset Mailing List 400"; | |
$headers = 'Content-Type: text/plain; charset=utf-8' . "\r\n"; | |
$headers .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n"; | |
$headers .= 'From: ' . $from . "\r\n"; | |
$headers .= 'Reply-To: ' . $support_mail . "\r\n"; | |
$headers .= 'Return-Path: ' . $support_mail . "\r\n"; | |
$params = array( | |
"host" => $smtp_host, | |
"port" => "25", | |
"auth" => true, | |
"username" => $system_mail, | |
"password" => "****" // Hidden for security reasons | |
); | |
$db_admins = $pdo->query("select * from `site_users` where `user_type` = 'admin' and `user_id` != '" . addslashes($dato_users["user_id"]) . "'"); | |
if($db_admins->rowCount() > 0) { | |
while($dato_admin = $db_admins->fetch()) { | |
$users[$i]["admins"][] = $dato_admin["name"] . " " . $dato_admin["last_name"]; | |
} | |
} | |
if($dato_users["user_type"] == "admin") { | |
$moderator_message = "\n" . $dato_users["name"] . " un'ultima cosa: risulti tra gli amministratori delle Mail perché sei stato iscritto alla ML " . $support_mail . " ma non hai un NIC per la gestione delle stesse.\n"; | |
$moderator_message .= "Dovresti recarti a questa pagina e crearti un account: https://www.ovh.it/cgi-bin/nic/newNic.cgi, dopodiché parlane con " . $main_admin_name . " che dovrà associarti manualmente alla piattaforma di gestione.\n"; | |
} else { | |
$moderator_message = ""; | |
} | |
$body = str_replace( | |
array( | |
"{NAME}", | |
"{NEW_EMAIL}", | |
"{OLD_EMAIL}", | |
"{EMAIL_PASS}", | |
"{MODERATOR_NAMES}", | |
"{MODERATOR_MESSAGE}" | |
), | |
array( | |
$dato_users["name"], | |
$dato_users["email"], | |
$dato_users["email2"], | |
$dato_users["email_passwd_temp"], | |
(count($users[$i]["admins"]) == 2) ? implode(" o ", $users[$i]["admins"]) : str_replace(", " . $users[$i]["admins"][2], " o " . $users[$i]["admins"][2], implode(", ", $users[$i]["admins"])), | |
$moderator_message | |
), | |
$email_text | |
); | |
// Feedback for developing | |
/* | |
if(mail($to, $subject, $body, $headers)) { | |
print "ok"; | |
} | |
*/ | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment