国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Konfigurieren Sie PHPMailer für die Verwendung von Office 365 SMTP
P粉510127741
P粉510127741 2023-10-16 10:39:47
0
2
1110

Ich versuche, PHPMailer so einzurichten, dass einer unserer Kunden automatisch E-Mails von seinem eigenen Konto generieren kann. Ich habe mich bei ihrem Office 365-Konto angemeldet und festgestellt, dass die erforderlichen Einstellungen für PHPMailer sind:

Host: smtp.off   ice365.com
Port: 587
Auth: tls

Ich habe diese Einstellungen auf PHPMailer angewendet, aber es werden keine E-Mails gesendet (die Funktion, die ich aufrufe, ist für unsere eigenen E-Mails, die von einem externen Server gesendet werden (nicht dem, der die Webseite bedient)).

"host"      => "smtp.of   fice365.com",
"port"      => 587,
"auth"      => true,
"secure"    => "tls",
"username"  => "clientemail@off  ice365.com",
"password"  => "clientpass",
"to"        => "myemail",
"from"      => "clientemail@of  fice365.com",
"fromname"  => "clientname",
"subject"   => $subject,
"body"      => $body,
"altbody"   => $body,
"message"   => "",
"debug"     => false

Wei? jemand, welche Einstellungen erforderlich sind, damit PHPMailer über smtp.offi ce365.com senden kann?

P粉510127741
P粉510127741

Antworte allen(2)
P粉176151589

更新:2022 年 5 月

所以我在這個問題上苦苦掙扎。對于具有 Exchange Online 和 Microsoft 管理中心訪問權(quán)限的企業(yè)帳戶,我可以提供此問題的答案。

TLDR:轉(zhuǎn)到管理中心并選擇您要發(fā)送郵件的用戶。然后在設(shè)置“經(jīng)過身份驗(yàn)證的 SMTP”之后查看“電子郵件”和“電子郵件應(yīng)用程序”后的設(shè)置,只需啟用它即可。

仍然無法工作?我已經(jīng)為您提供了幫助,這就是我如何讓它完全發(fā)揮作用。

  1. 使用PHP Composer,實(shí)際上節(jié)省了很多工作。
  2. 將您的代碼替換為我的代碼,并在測試后更改
SMTPDebug = SMTP::DEBUG_off;

//SMTP
$mail = new PHPMailer(true); //important
$mail->CharSet = 'UTF-8';  //not important
$mail->isSMTP(); //important
$mail->Host = 'smtp.office365.com'; //important
$mail->Port       = 587; //important
$mail->SMTPSecure = 'tls'; //important
$mail->SMTPAuth   = true; //important, your IP get banned if not using this

//Auth
$mail->Username = 'yourname@mail.org';
$mail->Password = 'your APP password';//Steps mentioned in last are to create App password

//Set who the message is to be sent from, you need permission to that email as 'send as'
$mail->SetFrom('hosting@mail.org', 'Hosting Group Inc.'); //you need "send to" permission on that account, if dont use yourname@mail.org

//Set an alternative reply-to address
$mail->addReplyTo('no-reply@mail.com', 'First Last');

//Set who the message is to be sent to
$mail->addAddress('customer@othermail.com', 'SIMON MüLLER');
//Set the subject line
$mail->Subject = 'PHPMailer SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('replace-with-file.html'), __DIR__);  //you can also use $mail->Body = "This is a body message in html" 
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('../../../images/phpmailer_mini.png');

//send the message, check for errors
if (!$mail->send()) {
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
}
  1. 這可能看起來像您的文件,沒關(guān)系,但現(xiàn)在是簡單棘手的部分。與 Google 一樣,Microsoft 也為 SMTP 實(shí)現(xiàn)了“開關(guān)”。只需從您的企業(yè)帳戶轉(zhuǎn)到您的管理中心,或者請有權(quán)限的人執(zhí)行該部分操作即可:
  • 導(dǎo)航至https://admin.microsoft.com/AdminPortal/Home#/users
  • 選擇您要從中發(fā)送電子郵件的用戶
  • 在“電子郵件”標(biāo)簽下搜索“電子郵件應(yīng)用程序”,點(diǎn)擊“管理電子郵件應(yīng)用程序”
  • 您可以在此處選擇“經(jīng)過身份驗(yàn)證的 SMTP”,確保選中該選項(xiàng)并保存更改
  1. 如果您使用 MFA,請確保使用 https://stackoverflow.com/ 中提到的應(yīng)用密碼a/61359150/14148981

  2. 運(yùn)行腳本

我希望這對某人有幫助。我花了很長時間才找到這個選項(xiàng)。

獲取應(yīng)用密碼和身份驗(yàn)證的所有步驟摘要:

  1. 使用管理員帳戶:
  • Active Directory AD -> 屬性 -> 安全默認(rèn)值:關(guān)閉。
  • Active Directory 門戶 -> 條件訪問 -> 配置 MFA 可信 IP -> 允許用戶應(yīng)用程序密碼:啟用
  • 管理頁面用戶列表 -> 目標(biāo)用戶的“多重身份驗(yàn)證”:啟用然后強(qiáng)制
  • 管理頁面用戶列表 -> 用戶詳細(xì)信息 -> 郵件 -> “管理電子郵件應(yīng)用程序” -> “經(jīng)過身份驗(yàn)證的 SMTP”:啟用
  1. 使用用戶帳戶:
  • 用戶帳戶配置文件 -> 安全 -> 添加登錄方法:應(yīng)用密碼
  1. PHP 郵件程序設(shè)置:
  • smtp.office365.com、587、tls、電子郵件、appPassword
P粉395056196

@nitin 的代碼對我不起作用,因?yàn)樗?SMTPSecure 參數(shù)中缺少“tls”。

這是一個工作版本。我還添加了兩行注釋掉的行,您可以在出現(xiàn)問題時使用它們。

isSMTP();
$mail->Host = 'smtp.office365.com';
$mail->Port       = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth   = true;
$mail->Username = 'somebody@somewhere.com';
$mail->Password = 'YourPassword';
$mail->SetFrom('somebody@somewhere.com', 'FromEmail');
$mail->addAddress('recipient@domain.com', 'ToEmail');
//$mail->SMTPDebug  = 3;
//$mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; //$mail->Debugoutput = 'echo';
$mail->IsHTML(true);

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body in bold!';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage