Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.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';使用office365的默认邮件()函数_Php_Email_Smtp_Office365_Phpmailer - Fatal编程技术网

使用php';使用office365的默认邮件()函数

使用php';使用office365的默认邮件()函数,php,email,smtp,office365,phpmailer,Php,Email,Smtp,Office365,Phpmailer,有没有办法在php.ini或其他地方设置SMTP设置,以使默认的mail()函数与我的office365邮件帐户一起工作?我不喜欢像PHPMailer那样使用API PHP mailer的问题是,它不会发送出网站所在的域,我得到的错误是:“无法实例化邮件函数。” 除了PHPmailer可以正常工作外,你知道如何解决这个问题吗? 当我将“$改为”行时,我将得到错误 use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Excepti

有没有办法在php.ini或其他地方设置SMTP设置,以使默认的mail()函数与我的office365邮件帐户一起工作?我不喜欢像PHPMailer那样使用API


PHP mailer的问题是,它不会发送出网站所在的域,我得到的错误是:“无法实例化邮件函数。”

除了PHPmailer可以正常工作外,你知道如何解决这个问题吗? 当我将“$改为”行时,我将得到错误

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

require '../../lib/src/Exception.php';
require '../../lib/src/PHPMailer.php';
require '../../lib/src/SMTP.php';

$to = 'info@***.nl';
$subject = 'PHPMailer GMail SMTP test';
$message = "test body";

$mailer = new PHPMailer;
//$mailer->isSMTP(); 
$mailer->SMTPDebug = 2; // 0 = off (for production use) - 1 = client messages - 2 = client and server messages
$mailer->Host = "smtp.office365.com"; // use $mailer->Host = gethostbyname('smtp.gmail.com'); // if your network does not support SMTP over IPv6
$mailer->Port = ***; // TLS only
$mailer->SMTPSecure = 'tls'; // ssl is depracated
$mailer->SMTPAuth = true;
$mailer->Username = '***';
$mailer->Password = '***';
$mailer->setFrom('noreply@***.nl','**',0);
$mailer->addAddress($to, '**');
$mailer->addReplyTo('info@**.nl','**');
$mailer->Subject = $subject;
$mailer->msgHTML($message); //$mailer->msgHTML(file_get_contents('contents.html'), __DIR__); //Read an HTML message body from an external file, convert referenced images to embedded,
$mailer->AltBody = 'HTML messaging not supported';
// $mailer->addAttachment('images/phpmailer_mini.png'); //Attach an image file

if(!$mailer->send()){
    //echo "Mailer Error: " . $mailer->ErrorInfo;
    echo 0;
}else{
    echo 1;
    //$_SESSION['mailerfeedback'] = "Bedankt voor je bericht!";
    //header('Location: contact.php');
}

您使用的是本地主机服务器还是主机服务器

如果您正在运行主机服务器,请与主机服务器提供商联系

如果您在本地主机服务器上运行,请确保您的计算机上也有本地主机邮件服务器。邮件服务器无法连接到您的SMTP服务器

要进行配置,请打开php.ini文件,搜索[mail function],更改邮件服务器的详细信息。这可以是本地邮件服务器或ISP的邮件服务器

[mail function]
SMTP = mail.yourserver.com
smtp_port = 25
auth_username = smtp-username
auth_password = smtp-password
sendmail_from = you@yourserver.com
保存php.ini后,重新启动服务器。 然后登录您的邮件帐户,转到设置并启用IMAP


如果您的本地计算机上没有邮件服务器,那么最好下载可用的库,如PHPMailer、PEAR、Fake sendmail……有许多资源向您展示如何设置和配置本地邮件服务器。

您使用的是本地主机服务器还是主机服务器

如果您正在运行主机服务器,请与主机服务器提供商联系

如果您在本地主机服务器上运行,请确保您的计算机上也有本地主机邮件服务器。邮件服务器无法连接到您的SMTP服务器

要进行配置,请打开php.ini文件,搜索[mail function],更改邮件服务器的详细信息。这可以是本地邮件服务器或ISP的邮件服务器

[mail function]
SMTP = mail.yourserver.com
smtp_port = 25
auth_username = smtp-username
auth_password = smtp-password
sendmail_from = you@yourserver.com
保存php.ini后,重新启动服务器。 然后登录您的邮件帐户,转到设置并启用IMAP


如果您的本地计算机上没有邮件服务器,那么最好下载可用的库,如PHPMailer、PEAR、Fake sendmail…有许多资源向您展示如何设置和配置本地邮件服务器。

您需要在服务器上设置sendmail,并通过smtp设置来配置它。对不起,我的英语不好。您需要在服务器上安装sendmail,并通过smtp设置对其进行配置。对不起,我的英语不好。PHPMailer的问题是,当我将邮件发送到网站所在的域外时,它会给出一个错误:“无法实例化邮件功能。”。除此之外,PHPMailer也可以。有没有办法解决这个问题?(我会在上面加上我的代码)我忘了;它正在主机服务器上运行。请尝试以这种方式初始化:$mailer->isSMTP();“无法实例化邮件功能”错误意味着您没有配置本地邮件服务器,即PHPMailer没有问题。SMTP无疑是一种更好的方式(它更快、更安全),但要求您的ISP允许出站远程SMTP,而许多人不允许。PHPMailer的问题是,当我将邮件发送到网站所在的域外时,它会给出一个错误:“无法实例化邮件功能。”。除此之外,PHPMailer也可以。有没有办法解决这个问题?(我会在上面加上我的代码)我忘了;它正在主机服务器上运行。请尝试以这种方式初始化:$mailer->isSMTP();“无法实例化邮件功能”错误意味着您没有配置本地邮件服务器,即PHPMailer没有问题。SMTP无疑是一种更好的方式(它更快、更安全),但要求您的ISP允许出站远程SMTP,而许多ISP不允许。