Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 由于邮件错误,无法注册到我的应用程序_Php_Html_Macos_Sendmail - Fatal编程技术网

Php 由于邮件错误,无法注册到我的应用程序

Php 由于邮件错误,无法注册到我的应用程序,php,html,macos,sendmail,Php,Html,Macos,Sendmail,我正试图在swift3中为iOS制作一个应用程序,但当我尝试注册时,我收到了一个邮件错误(为了完成注册,我使用电子邮件激活链接进行了注册) register.php // include email.php require ("secure/email.php"); // store all class in $email var $email = new email(); // store generated token in $token var $token = $email-

我正试图在swift3中为iOS制作一个应用程序,但当我尝试注册时,我收到了一个邮件错误(为了完成注册,我使用电子邮件激活链接进行了注册)

register.php

    // include email.php
require ("secure/email.php");

// store all class in $email var
$email = new email();

// store generated token in $token var
$token = $email->generateToken(20);

// save inf in 'emailTokens' table
$access->saveToken("emailTokens", $user["id"], $token);

// refer emailing information
$details = array();
$details["subject"] = "Email confirmation on Twitter";
$details["to"] = $user["email"];
$details["fromName"] = "Akhmed Idigov";
$details["fromEmail"] = "akhmedidigov@gmail.com";

// access template file
$template = $email->confirmationTemplate();

// replace {token} from confirmationTemplate.html by $token and store all content in $template var
$template = str_replace("{token}", $token, $template);

$details["body"] = $template;

$email->sendEmail($details);


  } else {
   $returnArray["status"] = "400";
   $returnArray["message"] = "Could not register with provided 
     infomraiton";
     }
class email {


// Generate unique token for user when he got confirmation email message
function generateToken($length) {

    // some characters
    $characters = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";

    // get length of characters string
    $charactersLength= strlen($characters);

    $token = '';

    // generate random char from $characters every time until it is less than $charactersLength
    for ($i = 0; $i < $length; $i++) {
        $token .= $characters[rand(0, $charactersLength-1)];
    }

    return $token;

}


// Open confirmation template user gonna receive
function confirmationTemplate() {

    // open file
    $file = fopen("templates/confirmationTemplate.html", "r") or die("Unable to open file");

    // store content of file in $template var
    $template = fread($file, filesize("templates/confirmationTemplate.html"));

    fclose($file);

    return $template;

}


// Open confirmation template user gonna receive
function resetPasswordTemplate() {

    // open file
    $file = fopen("templates/resetPasswordTemplate.html", "r") or die("Unable to open file");

    // store content of file in $template var
    $template = fread($file, filesize("templates/resetPasswordTemplate.html"));

    fclose($file);

    return $template;

}


// Send email with php
function sendEmail($details) {

    // information of email
    $subject = $details["subject"];
    $to = $details["to"];
    $fromName = $details["fromName"];
    $fromEmail = $details["fromEmail"];
    $body = $details["body"];

    // header required by some of smtp or mail sites
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;content=UTF-8" . "\r\n";
    $headers .= "From: " . $fromName . " <" . $fromEmail . ">" . "\r\n"; // From Akhmed Idigov <akhmed@gmail.com>

    // php func to send email finaly
    mail($to, $subject, $body, $headers);

}


}



?>
email.php

    // include email.php
require ("secure/email.php");

// store all class in $email var
$email = new email();

// store generated token in $token var
$token = $email->generateToken(20);

// save inf in 'emailTokens' table
$access->saveToken("emailTokens", $user["id"], $token);

// refer emailing information
$details = array();
$details["subject"] = "Email confirmation on Twitter";
$details["to"] = $user["email"];
$details["fromName"] = "Akhmed Idigov";
$details["fromEmail"] = "akhmedidigov@gmail.com";

// access template file
$template = $email->confirmationTemplate();

// replace {token} from confirmationTemplate.html by $token and store all content in $template var
$template = str_replace("{token}", $token, $template);

$details["body"] = $template;

$email->sendEmail($details);


  } else {
   $returnArray["status"] = "400";
   $returnArray["message"] = "Could not register with provided 
     infomraiton";
     }
class email {


// Generate unique token for user when he got confirmation email message
function generateToken($length) {

    // some characters
    $characters = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";

    // get length of characters string
    $charactersLength= strlen($characters);

    $token = '';

    // generate random char from $characters every time until it is less than $charactersLength
    for ($i = 0; $i < $length; $i++) {
        $token .= $characters[rand(0, $charactersLength-1)];
    }

    return $token;

}


// Open confirmation template user gonna receive
function confirmationTemplate() {

    // open file
    $file = fopen("templates/confirmationTemplate.html", "r") or die("Unable to open file");

    // store content of file in $template var
    $template = fread($file, filesize("templates/confirmationTemplate.html"));

    fclose($file);

    return $template;

}


// Open confirmation template user gonna receive
function resetPasswordTemplate() {

    // open file
    $file = fopen("templates/resetPasswordTemplate.html", "r") or die("Unable to open file");

    // store content of file in $template var
    $template = fread($file, filesize("templates/resetPasswordTemplate.html"));

    fclose($file);

    return $template;

}


// Send email with php
function sendEmail($details) {

    // information of email
    $subject = $details["subject"];
    $to = $details["to"];
    $fromName = $details["fromName"];
    $fromEmail = $details["fromEmail"];
    $body = $details["body"];

    // header required by some of smtp or mail sites
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;content=UTF-8" . "\r\n";
    $headers .= "From: " . $fromName . " <" . $fromEmail . ">" . "\r\n"; // From Akhmed Idigov <akhmed@gmail.com>

    // php func to send email finaly
    mail($to, $subject, $body, $headers);

}


}



?>
class电子邮件{
//当用户收到确认电子邮件时为其生成唯一令牌
函数generateToken($length){
//一些人物
$characters=“qwertyuiopasdfghjklzxcvnmqwertyuiopasdfghjklzxcvnm1234567890”;
//获取字符串的长度
$charactersLength=strlen($characters);
$token='';
//每次从$characters生成随机字符,直到它小于$charactersLength
对于($i=0;$i<$length;$i++){
$token.=$characters[rand(0,$charactersLength-1)];
}
返回$token;
}
//打开用户将收到的确认模板
函数确认模板(){
//打开文件
$file=fopen(“templates/confirmationTemplate.html”,“r”)或die(“无法打开文件”);
//将文件内容存储在$template var中
$template=fread($file,filesize(“templates/confirmationTemplate.html”);
fclose($文件);
返回$template;
}
//打开用户将收到的确认模板
函数resetPasswordTemplate(){
//打开文件
$file=fopen(“templates/resetPasswordTemplate.html”,“r”)或die(“无法打开文件”);
//将文件内容存储在$template var中
$template=fread($file,filesize(“templates/resetPasswordTemplate.html”);
fclose($文件);
返回$template;
}
//用php发送电子邮件
发送电子邮件功能($details){
//电子邮件信息
$subject=$details[“subject”];
$to=$details[“to”];
$fromName=$details[“fromName”];
$fromEmail=$details[“fromEmail”];
$body=$details[“body”];
//某些smtp或邮件站点需要的标头
$headers=“MIME版本:1.0”。\r\n”;
$headers.=“内容类型:text/html;内容=UTF-8”“\r\n”;
$headers.=“From:”$fromName.“\r\n”;//来自Akhmed Idigov
//php func最终发送电子邮件
邮件($to、$subject、$body、$headers);
}
}
?>

这是我注册时得到的


如果需要,我可以提供任何其他信息。

这似乎与Swift、iOS或Objective-C无关。运行php的macOS服务器上的sendmail存在问题。我应该怎么做,或者在哪里可以找到帮助?我需要尽快解决这个问题。感谢安装支持邮件的服务器?购买支持邮件的主机?我遵循了一个教程,我所做的是编辑/etc/postfix/main.cf文件以添加一些行(relayhost=smtp.gmail.com:587/smtp_sasl_auth_enable=yes和其他行)。。。奇怪的是,我参加了日期邮件测试xx@gmail.com我收到了这封电子邮件。怎么了?没人能帮我(