Created
May 11, 2017 15:39
-
-
Save strangerstudios/7c1952f167ddd39274de200e1a87eef3 to your computer and use it in GitHub Desktop.
Sends a text reminder via PHP/PEAR Mail/PEAR Net_SMTP
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 | |
/* | |
1. Make sure PEAR Mail and PEAR Net_SMTP are installed. | |
2. Add this php script somewhere on your server. (Edit the appropriate lines.) | |
3. The script assumes a Gmail email and emailing a Verizon VText email address to send via text message. | |
4. Then add a crontab line like this somewhere send you a message every 2 hours. | |
55 */2 * * * php /var/scriptfolder/stillfat.php > /dev/null 2>&1 | |
*/ | |
require_once('Mail.php'); | |
date_default_timezone_set('America/New_York'); | |
echo "\n"; | |
$hour = date('H'); | |
if($hour > 8 && $hour < 20) { | |
$from = '@gmail.com'; | |
$to = '###@vtext.com'; | |
$subject = ''; | |
$message = "You're still fat. Eat well. Move your body."; | |
$message .= ' - ' . date('m/j/Y hA'); | |
$host = 'smtp.gmail.com'; | |
$username = '@gmail'; | |
$password = 'Password'; | |
$headers = array('From'=>$from, 'To'=>$to, 'Subject'=>$subject); | |
$smtp = Mail::Factory( | |
'smtp', | |
array( | |
'host'=>$host, | |
'auth'=>true, | |
'username'=>$username, | |
'password'=>$password | |
) | |
); | |
$mail = $smtp->send($to, $headers, $message); | |
if(PEAR::isError($mail)) | |
echo $mail->getMessage(); | |
else | |
echo "Message sent."; | |
} | |
echo "\n\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment