This topic is locked
[SOLVED]

 Send email on registration with event

8/18/2016 6:11:22 AM
PHPRunner General questions
R
ruud author

Can someone tell me how to send an Email with an event After Successful registration.
Thanks in advance
Ruud Wiering

romaldus 8/19/2016



Can someone tell me how to send an Email with an event After Successful registration.
Thanks in advance
Ruud Wiering


https://xlinesoft.com/phprunner/docs/after_successful_registration.htm

R
ruud author 8/22/2016



https://xlinesoft.com/phprunner/docs/after_successful_registration.htm


Thanks for the link. I have seen it, but I cannot figure out how to use: AfterSuccessfulRegistration($userdata,$pageObject)
Maybe you can give me some sample code?
Events and emailing is running smooth, but this one is ??
Thanks?

romaldus 8/22/2016



Thanks for the link. I have seen it, but I cannot figure out how to use: AfterSuccessfulRegistration($userdata,$pageObject)
Maybe you can give me some sample code?
Events and emailing is running smooth, but this one is ??
Thanks?


Example using PHPMAILER.

Download PHPMAILER from : https://github.com/PHPMailer/PHPMailer

and extract to root directory of your web app


//include

require 'PHPMailerAutoload.php';
//Create a new PHPMailer instance

$mail = new PHPMailer;
//Tell PHPMailer to use SMTP

$mail->isSMTP();
//Enable SMTP debugging

// 0 = off (for production use)

// 1 = client messages

// 2 = client and server messages

$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output

//$mail->Debugoutput = 'html';

$mail->IsHTML(true);
//Set the hostname of the mail server

$mail->Host = 'yourdomain.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission

$mail->Port = 25;
//Set the encryption system to use - ssl (deprecated) or tls

//$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication

$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail

$mail->Username = "userneme@yourdomain.com";
//Password to use for SMTP authentication

$mail->Password = "your_smtp_password";
//Set who the message is to be sent from

$mail->setFrom('userneme@yourdomain.com', 'John Doe');
//Set an alternative reply-to address

$mail->addReplyTo('userneme2@yourdomain.com', 'Bill Gates');
//Set who the message is to be sent to

$mail->addAddress($userdata["email"]);
$mail->addCC("anyaddress@gmail.com");
//Set the subject line

$mail->Subject = 'Halo, your message subject here';
$mail->Body = "Body of your message here";


R
ruud author 8/22/2016



Example using PHPMAILER.

Download PHPMAILER from : https://github.com/PHPMailer/PHPMailer

and extract to root directory of your web app


//include

require 'PHPMailerAutoload.php';
//Create a new PHPMailer instance

$mail = new PHPMailer;
//Tell PHPMailer to use SMTP

$mail->isSMTP();
//Enable SMTP debugging

// 0 = off (for production use)

// 1 = client messages

// 2 = client and server messages

$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output

//$mail->Debugoutput = 'html';

$mail->IsHTML(true);
//Set the hostname of the mail server

$mail->Host = 'yourdomain.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission

$mail->Port = 25;
//Set the encryption system to use - ssl (deprecated) or tls

//$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication

$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail

$mail->Username = "userneme@yourdomain.com";
//Password to use for SMTP authentication

$mail->Password = "your_smtp_password";
//Set who the message is to be sent from

$mail->setFrom('userneme@yourdomain.com', 'John Doe');
//Set an alternative reply-to address

$mail->addReplyTo('userneme2@yourdomain.com', 'Bill Gates');
//Set who the message is to be sent to

$mail->addAddress($userdata["email"]);
$mail->addCC("anyaddress@gmail.com");
//Set the subject line

$mail->Subject = 'Halo, your message subject here';
$mail->Body = "Body of your message here";



►► It is specific about sending an email after successful registration:
Description

Occurs when new user registered successfully
Parameters

$userdata - an array with the user-entered data. Access fields by

$userdata["FieldName"].

"dict" is an alternate name for this parameter.

$pageObject - an object of Page class representing the current page
► The following comes up after adding the code:
// ** Send simple email ****

$email="test@test.com";

$from="admin@test.com";

$msg="Hello there\nBest regards";

$subject="Sample subject";

$attachments = array();

// Attachments description. The 'path' is required. Others parameters are optional.

// $attachments = array(

// array('path' => getabspath('files/1.jpg')),

// array('path' => getabspath('files/2.jpg'), 'name' => 'image.jpg', 'encoding' => 'base64', 'type' => 'application/octet-stream')) ;
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from, 'attachments' => $attachments));

// You can manually overwrite SMTP settings

// $ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from, 'attachments' => $attachments,

// 'host' => 'somehost', 'port' => 25, 'username' => 'smtpUserName', 'password' => 'password'));

if(!$ret["mailed"])

echo $ret["message"];
This not functioning. It is however functioning at whatever page but not @ AfterSuccessfulRegistration.

So, I think I should do something with the parameters?:
Parameters

$userdata - an array with the user-entered data. Access fields by

$userdata["FieldName"].

"dict" is an alternate name for this parameter.

$pageObject - an object of Page class representing the current page
I hope it is clear. Thanks again?

Sergey Kornilov admin 8/23/2016

What sounds really strange to me is that basically the same email code works in all events except AfterSuccessfulRegistration. It just doesn't sound right.
There must be something in your code that prevents it from working.

R
ruud author 8/31/2016



What sounds really strange to me is that basically the same email code works in all events except AfterSuccessfulRegistration. It just doesn't sound right.
There must be something in your code that prevents it from working.


The code underneath does not work AfterSuccessfulRegistration but it works after record update of the user table record. What do I do wrong??
$email=$values['RegEmailPennMstr'];

$from=$values['EmailLogin'];

$msg="Er is een nieuwe registratie"."\r\n";

$subject="Nieuwe registratie geologie.nu";
$msg.= "Naam: ".$values["Naam"]."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

Sergey Kornilov admin 9/1/2016

There is no $values array in AfterSuccessfulRegistration event.
Please check the documentation:

http://xlinesoft.com/phprunner/docs/after_successful_registration.htm

emendoza 9/2/2016

Ruud Wiering, Two suggestions::

1- $values: you should change $values to $userdata. Not available variable $values in the AfterSuccessfulRegistration event. in this event, registered user data are captured in the variable $userdata
2- $from: putting the address in your "Email settings" In the "Misc" tab of your PHPRunner, for example: support@xlinesoft.com. Check "Email settings" here https://xlinesoft.com/phprunner/docs/user_login_settings.htm
//////////////////
$email=$userdata['RegEmailPennMstr'];

$from="user@yourdomain.com";

$msg="Er is een nieuwe registratie"."\r\n";

$subject="Nieuwe registratie geologie.nu";
$msg.= "Naam: ".$userdata["Naam"]."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
//////////////////