Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.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 无法使用WAMP和sendmail在本地发送邮件_Php_Email_Html Email_Sendmail - Fatal编程技术网

Php 无法使用WAMP和sendmail在本地发送邮件

Php 无法使用WAMP和sendmail在本地发送邮件,php,email,html-email,sendmail,Php,Email,Html Email,Sendmail,我正在从事一个php项目,我得到了一个应该向用户发送邮件的部分。我决定使用PHP函数mail()。每当我尝试下面的代码时,都会失败: //发送确认邮件 $confirmation\u link=”http://localhost/africafashion_newversion/confirm.php?id=$user_id&token=$token”; $to=$_POST['email']; $subject=“确认付款”; $message='1 “.$subject。” 你差不多完了

我正在从事一个php项目,我得到了一个应该向用户发送邮件的部分。我决定使用PHP函数
mail()
。每当我尝试下面的代码时,都会失败:

//发送确认邮件
$confirmation\u link=”http://localhost/africafashion_newversion/confirm.php?id=$user_id&token=$token”;
$to=$_POST['email'];
$subject=“确认付款”;
$message='1
“.$subject。”
你差不多完了

问题?评论?让我们知道我们的计划。

Stack Exchange Inc.纽约州威廉街110号28楼,邮编10038

'; //发送HTML电子邮件时始终设置内容类型 $headers=“MIME版本:1.0”。“\r\n”; $headers.=“内容类型:text/html;字符集=UTF-8”。“\r\n”; //更多标题 $headers.='From:'。“\r\n”; $headers.='Cc:myboss@example.com' . “\r\n”; if(邮件($to、$subject、$message、$headers)){ $\会话['flash']['success']='邮件已成功发送'; 标题('Location:login.php'); 退出(); }否则{ $\会话['flash']['danger']=“未发送确认邮件”; $req=$pdo->prepare('DELETE FROM UserID=?'的用户); $req->execute([$user_id]); 标题('Location:register.php'); 退出(); }
}
不要使用SendMail,您可以使用。它很简单,你可以在收件箱中发送电子邮件(而不是垃圾邮件!!!)。所以它会帮助你,节省你的时间

mysend.php的代码

include_once "inc/swift_required.php";

$subject = 'Hello from Jeet Patel, PHP!'; //this will Subject
$from = array('jeet@mydomain.com' =>'mydomain.com'); //you can use variable

$text = "This is TEXT PART";
$html = "<em>This IS <strong>HTML</strong></em>";

$transport = Swift_SmtpTransport::newInstance('abc.xyz.com', 465, 'ssl');
$transport->setUsername('MYUSERNAME@MYDOMAIN.COM');
$transport->setPassword('*********');
$swift = Swift_Mailer::newInstance($transport);



    $to = array($row['email']  => $row['cname']);
    $message = new Swift_Message($subject);
    $message->setFrom($from);
    $message->setBody($html, 'text/html');
    $message->setTo($to);
    $message->addPart($text, 'text/plain');

    if ($swift->send($message, $failures))
    {
        echo "Send successfulllyy";
    } else {
        print_r($failures);

    }
包括一次“inc/swift\u required.php”;
$subject='Jeet Patel,PHP,您好!'//这将取决于
$from=数组('jeet@mydomain.com'=>'mydomain.com')//可以使用变量
$text=“这是文本部分”;
$html=“这是html”;
$transport=Swift_SmtpTransport::newInstance('abc.xyz.com',465,'ssl');
$transport->setUsername('MYUSERNAME@MYDOMAIN.COM');
$transport->setPassword('********');
$swift=swift\u Mailer::newInstance($transport);
$to=数组($row['email']=>$row['cname']);
$message=新的Swift_消息($subject);
$message->setFrom($from);
$message->setBody($html,'text/html');
$message->setTo($to);
$message->addPart($text,'text/plain');
如果($swift->send($message,$failures))
{
回显“发送成功”;
}否则{
打印(失败);
}

您是否已进行任何配置设置以启用发送邮件?(因为这在Windows机器上不是给定的。)用户评论提供了如何实现这一点的技巧,例如,我在8小时前收到了邮件,在实现HTML格式邮件后,我收到了错误。不要认为故障来自
sendmail