This topic is locked

Sending information from the database via e-mail at record editing

2/23/2016 7:39:05 AM
PHPRunner General questions
kanclerz author

Hello

I am writing to you on this for almost I have a form where users are ordering an item, Beside giving their data shall also e-mail, I do not know how to do to edit the record with his application send him a return address such as a built-in button. Please help or have a hint PHPRunner 8.1

Sergey Kornilov admin 2/23/2016

Use 'AfterAdd' event and sample action 'Send email with new data':

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

kanclerz author 2/23/2016

but is not it true that there are defined only two addresses and mail me about sending to different email addresses which the user enters. Natomoast answer will come out with a defined mail such jankowalski@test.com
//** Send email with new data ****

$email="test@test.com";

$from="admin@test.com";

$msg="";

$subject="New data record";
$msg.= "Name: ".$values["name"]."\r\n";

$msg.= "Email: ".$values["email"]."\r\n";

$msg.= "Age: ".$values["age"]."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
A

romaldus 2/24/2016

download phpmailer from here : https://github.com/PHPMailer/PHPMailer
extract phpmailer in your project directory, include folder (yourproject/include)
in after add orafter edit event, use the following code to send mail using phpmailer:



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 = "youremail@yourdomain.com";
//Password to use for SMTP authentication

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

$mail->setFrom('youremail@yourdomain.com', 'Your name here');
//Set an alternative reply-to address

$mail->addReplyTo('youremail@yourdomain.com', 'Your name here');
//Set who the message is to be sent to (email address from your PHPRUNNER field)

$mail->addAddress($values["EMAIL_ADDRESS"]);
$mail->addCC("another_email_address@anydomain.com");
//Set the subject line

$mail->Subject = 'Your mail subject here';
$mail->Body = "<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=78871&image=1&table=forumreplies'>; \n
\n
Yth \n
<b>".$values["any_field_from_phprunner"]."</b> \n
Your email body here\n
//send the message, check for errors

if (!$mail->send()) {

echo "Mailer Error: " . $mail->ErrorInfo;

} else {

echo "";

}
Sergey Kornilov admin 2/24/2016

PHPMailer is already a part of PHPRunner. No need to add all this custom code.