I have created a registration and after successful registration user get a email about login details(this happens when user clicks submit button).But i have stuck with a sending another email automatically to the same user after 5 minutes and after 20 days user have registered.in the mysql database registration time saved as Time_created.(timestamp).[2016-04-26 10:25:30].what is the possible way to do this.
Here is my code to send email from form this works correctly.
$r = $_GET['rid'];
$aaaa= mysql_query("SELECT email FROM gotest WHERE ID= '$r'");
$bbbb = mysql_fetch_array($aaaa);
$email = $bbbb['email'];
$to = $email;
$subject = ' Site| login ';
$message = '
Thanks for signing up!
Your account has been created, you can login with the following credentials.
------------------------
Username: '.$name.'
Password: '.$pass.'
------------------------ ';
$headers .= 'From:noreply#xxx.net' . "\r\n";
$headers .= 'Bcc:zzz#xxx.net' ."\r\n";
mail($to, $subject, $message, $headers);
At the time of registration, add mail send date & set no_of_email_send=1. Set a cron which will check whether mail_send_date + 5 mints > now() & no_of_email_send == 1.If this condition satisfy, then send 2nd email & update mail send date & set no_of_email_send=2. If no_of_email_send == 2 then check mail send date + 20days > now() then send 3rd email & update mail send date & set no_of_email_send=3 You can do the validation using single query also.
Related
I'm using WP CRON say every week to check for users that will expire in 30 days using this
global $wpdb;
$daysPriorToRebill = 30;
$priorToRebillDate = date('Y-m-d', strtotime("+{$daysPriorToRebill} days"));
$todaydate = date('Y-m-d');
$sql3 = "SELECT DISTINCT wp_user_id
FROM mm_user_data
WHERE expiration_date <= '".$priorToRebillDate."' AND expiration_date >= '".$todaydate."'";
$userid = $wpdb->get_results($sql3);
$user_id = $userids->wp_user_id;
after I find these users I send them an email with a link to pay, once they pay, I have another function to extend their membership by year interval
$from_email = get_option('admin_email');
$to = $user_email;
$subject = "Hey update your membership;;
$headers = "";
$headers .= "From:" . $from_email . "\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "Message with link";
wp_mail($to, $subject, $message, $headers);
if they pay within a week, they will not recieve the next email, but if they take longer they will have to recieve this email again, is there a way to exclude users who already recieved the email in the next cron job. I'm thinking of inserting a specific value in a database field like 'sent' and checking against it, but not sure how to go about it or if there is a better way.
Your idea of adding a new field would work.
Another option would be to send emails only to those who would expire in 23-30 days, assuming the job runs weekly.
Alternatively run it daily and check only for expiring in exactly 30 days.
I am trying to send an email for multiple addresses that are retrieved from db
while($row = mysql_fetch_assoc($qry9)) {
$email=$row["email"];
$subject = "Testing";
$headers = "From: test#gmail.com \r\n";
$message='New Event Registered';
mail($email,$subject,$message,$headers);
}
In this given like $email="nandha181#gmail.com" is working properly but email from database is not working .I am also checking the email from the database query works correctly.
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
I have a PHP website wherein users fill in their registration details and an email goes to them with a link to activate their account. The problem is that sometimes the activation email goes and sometimes it doesnt. I want to make sure that after every registration the activation link email goes to the subscriber to activate his account. Right now there is no way to track this until the user tells us. To solve this I also want to get a copy of that email on my email address so that it acts as additional confirmation.
Here is the current code and any help to solve this would be highly appreciated -
$qq = "select * from quiz_tmpreg where id='".$_SESSION['uid']."'";
$ex = mysqli_query($dbcon, $qq);
$trp = mysqli_fetch_array($ex);
$ToEmail = $trp['email'];
$EmailSubject = "Registration Details";
$mailheader = "From: "."orders#company.com"."\r\n";
$mailheader .= "Reply-To: ".'orders#company.com'."\r\n";
$mailheader .= "Content-type: text/html; charset=utf-8\r\n";
$MESSAGE_BODY = " User Name :- " .$trp['uname']. ",<br>";
$MESSAGE_BODY .= " Password :- " .$trp['pass']. ",<br>";
$MESSAGE_BODY .= " Your Unique ID :- " .$_SESSION['uniq_id']. ",<br>";
$MESSAGE_BODY .= " Activation Link :- http://company.com/confirm.php? encrypt=".$_SESSION['uid']."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader);
unset($_SESSION['uid']);
you can test the result of mail() for any errors. php.net/mail()
as usual, you should present a hint after user's registration, tell him to check the inbox and his spam folder, and to contact you if they didn't receive an email.
you can use timetstamp of registration date to check if any users did sign up but didn't check back via the confirmation link after a certain time. if that happens a lot you can investigate more on that
I have a php script that should be sending an email when a registration is completed. This works fine where as soon as someone registered the email is sent and I receive it. However, I have noticed that sometimes I receive the same email about an hour afterwards. Sometimes it even suddenly sends me an email for a registration that was received weeks ago.
$key=$_GET[key];
if(isset($key) || !empty($key)){
$query1=mysql_query("SELECT * FROM registration WHERE value='$key'");
while($question_list = mysql_fetch_array($query1)){
$num_questions=mysql_num_rows($query1);
$title= $question_list['title'];
$firstname=$question_list['firstname'];
$lastname=$question_list['familyname'];
$dateofbirth=$question_list['dob'];
$gender=$question_list['gender'];
$nationality=$question_list['nationality'];
$email=$question_list['email'];
$to = "userregistration#yahoo.com";
$subject = "Registration";
$message = "Hello! Registration, see below."."\n";
$message.="\n";
$message.="Title: ";
$message.=$title."\n";
$message.="First Name: ";
$message.=$firstname."\n";
$message.="Last Name: ";
$message.=$lastname."\n";
$message.="Gender: ";
$message.=$gender."\n";
$message.="Date of Birth: ";
$message.=$dateofbirth."\n";
$message.="Nationality: ";
$message.=$nationality."\n";
$message.="Email Address: ";
$message.=$email."\n";
$message.="Telephone: ";
$message.=$telephone."\n";
$from = "registration#yahoo.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
}
}
Change your sql query to
"SELECT * FROM registration WHERE value='$key' LIMIT 0,1"
so that it will send mail only once
in you question list if you are getting 2 records from the table then you will end up sending a single mail twice.
I'm trying to do a password reset using mail, so what will happen is the user will enter his email on the forgot password and on button click it will be sent to the email that is on the database. Now what i will do is give the user a new random password and to do this the user should click on the link on the email to verify that he really wants to change the password, will that be possible? Here is my code
if (isset($_POST['mytxtmail']))
{
$newid = ($_POST['mytxtmail']);
$result = mysqli_query($con,"SELECT EMAIL FROM members WHERE EMAIL='$newid'");
if($result->num_rows == 0) {
echo 'Mail Successfully Sent to '.$newid;
return false;
}
else
$to = $newid;
$subject = 'the subject';
$message = 'Please Click here to Verify the Change of Password';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Mail Successfully Sent to '.$newid;
}
It's a bit of a long procedure to write the full code here.
One way you can do is, make a new column in your users table, let's say pass_request_hash , now whenever the user clicks on forgot password option and enters his e-mail ID and submits, an update query runs to dump a random value into pass_request_hash for that user and at the same time a mail is sent with that same hash value and also his e-mail ID as GET parameters.
Now when the user has clicked on the link sent to him by e-mail, the link points to a PHP script which checks with the database if the hash and e-mail received from the GET parameter matches with those in the database, if yes then you can have another script getting executed to send a new password to that e-mail ID.
You can also set a timeout for that hash.
There are other ways to do it too, check out some of these tutorials:
One
Two
Three
You should include the link in the email which would take the user to the password verification script (it could be the same you are using here, only add needed functionality).