簡體   English   中英

單擊並使用A-Frame和php將郵件發送給用戶

[英]Click and send mail to user using A-Frame and php

我想通過使用框架點擊按鈕來發送電子郵件。 我做了一些,但是那沒用。 這是工作流程。 我有數據庫,正在獲取用戶電子郵件表單數據庫。 這是html:

<a-plane id="information-button" name="button-press" class="clickable" 
 position="6 -4.845 3" rotation="0 -30 0" width="3" height="1" color="#000">
      <a-text value="More Info" position="-0.946 0.077 0.349" scale="2 2 2"> 
      </a-text>
</a-plane>

這是email.php發送電子郵件。

<?php 
include('server.php');
session_start();
?>
<?php 
if (isset($_POST['button-press'])) {
require "PHPMailer/src/PHPMailer.php";
require "PHPMailer/src/OAuth.php";
require "PHPMailer/src/SMTP.php";
require "PHPMailer/src/POP3.php";
require "PHPMailer/src/Exception.php";
require 'PHPMailer/src/PHPMailerAutoload.php';

use PHPMailer\PHPMailer\PHPMailer; 
use PHPMailer\PHPMailer\Exception;

if (isset($_SESSION['email'])){
    $headers = "MIME-Version: 1.0" . '\r\n';
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . '\r\n'; 
    $message = '<p><strong>You are in.</strong></p>';
    $subj = 'More Information';
    $to = 'falak@oddly.co';
    $from = 'falaksabbir3@gmail.com';

define('GUSER', 'falaksabbir3@gmail.com'); // GMail username
define('GPWD', '******');
define('SMTPUSER', 'falaksabbir3@gmail.com'); // sec. smtp username
define('SMTPPWD', '******'); // sec. password
define('SMTPSERVER', 'smtp.gmail.com'); // sec. smtp server



//send mail

if ( smtpmailer($to, $from, $name, $subj, $message,$headers)){
        echo 'Message send via Gmail';
    } else {
        if (!smtpmailer($to, $from, $name, $subj, $message,$headers)){
            if (!empty($error)) echo $error;
        } else {
            echo 'Yep, the message is send (after doing some hard work)';
        }
    }

//send email function

function smtpmailer($to, $from, $from_name, $subject, $body, $is_gmail = true) { 
    global $error;
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPAuth = true; 
    if ($is_gmail) {
        $mail->SMTPSecure = 'ssl'; 
        $mail->Host = 'ssl://smtp.gmail.com';
        $mail->Port = 465;  
        $mail->Username = GUSER;  
        $mail->Password = GPWD;   
    } 
    else {
        $mail->Host = SMTPSERVER;
        $mail->Username = SMTPUSER;  
        $mail->Password = SMTPPWD;
    }        
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->IsHTML(true); 
    $mail->AddAddress($to); 
    if(!$mail->Send()) {
        $error = 'Mail error: '.$mail->ErrorInfo;
        return false;
    } else {
        $error = 'Message sent!';
        return true;
    }
}
}}
?>

這就是我的做法。 我可以用aframe做php嗎? 或與此有關的任何准則。

是的,您可以使用A-Frame執行PHP。

目前,盡管您的A-Frame代碼無法與PHP代碼進行交互。 您希望您的操作(是否在VR中)調用服務器。 我建議:

  1. 只需訪問頁面即可使發送操作生效
  2. 確保它在沒有VR的情況下也能正常工作,例如使用簡單的HTML按鈕如何在單擊按鈕時調用PHP函數
  3. 最終可能使用光標和一些JavaScript將它與VR和A-Frame一起使用https://aframe.io/docs/0.8.0/components/cursor.html#example

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM