programing

로컬 호스트에서 메일을 보내도록 XAMPP를 설정하려면 어떻게 해야 합니까?

goodjava 2023. 1. 15. 16:54

로컬 호스트에서 메일을 보내도록 XAMPP를 설정하려면 어떻게 해야 합니까?

localhost에서 메일을 보내려고 합니다.localhost에서 메일을 보낼 수 없습니다.localhost에서 메일을 보내도록 xampp를 재설정하는 방법을 알려주시겠습니까?

sendmail 패키지와 함께 localhost에서 메일을 보낼 수 있습니다. sendmail 패키지는 XAMPP에 인빌드되어 있습니다.따라서 XAMPP를 사용하는 경우 localhost에서 메일을 쉽게 보낼 수 있습니다.

, '어울리다', '어울리다'를 설정할 수 .C:\xampp\php\php.ini ★★★★★★★★★★★★★★★★★」c:\xampp\sendmail\sendmail.ini mail메일을 보냅니다.

C:\xampp\php\php.iniextension=php_openssl.dll 행의 선두에서 을 삭제하고, localhost gmail이 SSL로 .

php에서 php.ini를 .[mail function] 변경 ★★★

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

★★★★★★★★★★★★★★를 엽니다.C:\xampp\sendmail\sendmail.inisendmail (다음 코드 포함)

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com

이제 끝!!메일 기능으로 php 파일을 생성하여 localhost에서 메일을 보냅니다.

PS: 상기 코드의 my-gmail-idmy-gmail-password를 교체하는 것을 잊지 마십시오.또, 위에서 설정을 카피했을 경우는, 중복 키를 삭제하는 것도 잊지 말아 주세요.예를 들어 다른 sendmail_path가 있는 경우 다음 행을 코멘트합니다.sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" php.ini 파일 php.ini 파일

또, XAMMP 제어판을 사용해 서버를 재기동해, 변경을 유효하게 하는 것도 잊지 말아 주세요.

gmail의 경우 보안이 낮은 앱에서 액세스를 허용하려면 https://support.google.com/accounts/answer/6010255을 확인하십시오.

localhost에서 Gmail을 통해 Linux(sendmail 패키지 포함)로 이메일을 보내려면 localhost에서 gmail 형식을 사용하여 PHP+Ubuntu 이메일 보내기를 선택하십시오.

XAMPP v3.2.1 에서는, XAMPP 가 XAMPP/mail 출력으로 송신하는 전자 메일을 확인할 수 있습니다.Windows 8 의 경우는, 추가 설정이 필요 없고, E-메일 테스트의 심플한 솔루션입니다.

인터넷 없이 PC에서 메일 전송 테스트 가능

이 간단한 응용 프로그램을 사용하여 메일 발송을 테스트해야 합니다.아무것도 설정할 필요가 없습니다.

실행 후 테스트 메일 전송을 시도합니다.

test_sendmail 입니다.php

<?php
$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";

mail($to,$subject,$txt,$headers);
?>

다음과 같이 표시됩니다.

여기에 이미지 설명 입력

좋은 하루 되시길 바랍니다.당신은 나를 유튜브에서 더 많은 튜토리얼 Piseth Sok을 찾을 수 있습니다.

응원!

로컬 호스트 또는 로컬 서버에서 이메일을 보내는 것은 매우 간단합니다.

주의: Xampp가 설치되어 있는 Windows 7 64비트에서 테스트 메일 서버 소프트웨어를 사용하고 있습니다.

테스트 메일 서버 도구를 다운로드하여 웹 사이트의 지시에 따라 설치하기만 하면 됩니다.테스트 메일 서버

이번에는 두 .php.ini

  1. ★★[mail function] 반장 하기 전에 은 제거해 주세요.;smtp = localhost
  2. 앞에 .sendmail_path = "C:\xampp\mailtodisk\mailtodisk.exe"

바꿔도 되지만 이 안 ' 낫다', '알겠습니다', '알겠습니다.'SMTP port포트 번호는 같아야 합니다.

위의 방법은 Xampp 소프트웨어에 의해 제공되는 기본 설정입니다.

서버에 SMTP 를 설정할 필요가 있습니다.G Suite SMTP by Google은 무료로 사용할 수 있습니다.

<?php

$mail = new PHPMailer(true);

// Send mail using Gmail
if($send_using_gmail){
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->SMTPAuth = true; // enable SMTP authentication
    $mail->SMTPSecure = "ssl"; // sets the prefix to the servier
    $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
    $mail->Port = 465; // set the SMTP port for the GMAIL server
    $mail->Username = "your-gmail-account@gmail.com"; // GMAIL username
    $mail->Password = "your-gmail-password"; // GMAIL password
}

// Typical mail data
$mail->AddAddress($email, $name);
$mail->SetFrom($email_from, $name_from);
$mail->Subject = "My Subject";
$mail->Body = "Mail contents";

try{
    $mail->Send();
    echo "Success!";
} catch(Exception $e){
    // Something went bad
    echo "Fail :(";
}

?>

은 이쪽PHPMailer 여기 있습니다.

내 개인적인 경험에서 보듯이, 나는 Vikas Dwivedi의 대답과 매우 유사한 것이 잘 작동한다는 것을 알았다.

스텝 1(php.ini 파일)

있는 php.ini 파일xampp\php\php.ini. 과 같이 설정을 다음과 같이 변경합니다.

 extension=php_openssl.dll
 [mail function]
 sendmail_path =":\xampp7\sendmail\sendmail.exe -t"
 mail.add_x_header=On

음음음 under under under under under under under under under under under の 다른 변수 끄기mail funciton퍼팅 putting putting putting ; 그 전에,;smtp_port=25

스텝 2(sendmail.ini 파일)

xampp\sendmail\semdmail에 있는 sendmail.ini.ini를 다음과 같이 변경합니다.

 smtp_server=smtp.gmail.com
 smtp_port=465
 smtp_ssl=auto
 auth_username=address@gmail.com
 auth_password=YourPassword

스텝 3(코드)

php 파일을 만들고 다음을 사용합니다.

 <?php
    mail($to, "subject", "body", "From: ".$from);
 ?>

공지

  • php.ini를 새로고침하려면 apache를 재시작해야 합니다.
  • https://myaccount.google.com/u/1/security에서 Google Less secure 앱 액세스를 활성화해야 합니다.
  • 관리자 권한으로 Xampp를 실행하면 도움이 될 수 있습니다.

이 코드는 로컬 호스트 XAMPP 및 Gmail 계정에서 보내는 메일에 사용됩니다.이 코드는 매우 쉬우므로 직접 사용해 보십시오.

아래 php.ini 파일 변경

SMTP=smtp.gmail.com 
smtp_port=587 
sendmail_from = your@gmail.com 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 
extension=php_openssl.dll 

[ Change In in sendmail ]아래.ini 파일

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log 
auth_username=yourmail@gmail.com 
auth_password=your-gmail-password 
force_sender=yourmail@gmail.com  

이메일을 보내려면 PHP 파일에 belove 코드를 적어주세요.

<?php 
    $to = "tomail@gmail.com";
    $subject = "Test Mail";
    $headers = "From: from_mail@gmail.com\r\n";
    $headers .= "Reply-To: replytomail@gmail.com\r\n";
    $headers .= "CC: theassassin.edu@gmail.com\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    $message = '<html><body>';
    $message .= '<img src="//css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';
    $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
    $message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>Details</td></tr>";
    $message .= "<tr><td><strong>Email:</strong> </td><td>Details</td></tr>";
    $message .= "<tr><td><strong>Type of Change:</strong> </td><td>Details</td></tr>";
    $message .= "<tr><td><strong>Urgency:</strong> </td><td>Details</td></tr>";
    $message .= "<tr><td><strong>URL To Change (main):</strong> </td><td>Details</td></tr>";
    $addURLS = 'google.com';
    if (($addURLS) != '') {
        $message .= "<tr><td><strong>URL To Change (additional):</strong> </td><td>" . $addURLS . "</td></tr>";
    }
    $curText = 'dummy text';           
    if (($curText) != '') {
        $message .= "<tr><td><strong>CURRENT Content:</strong> </td><td>" . $curText . "</td></tr>";
    }
    $message .= "<tr><td><strong>NEW Content:</strong> </td><td>New Text</td></tr>";
    $message .= "</table>";
    $message .= "</body></html>";

    if(mail($to,$subject,$message,$headers))
    {
        echo "Mail Send Sucuceed";
    }
    else{
        echo "Mail Send Failed";    
    }
?>

모든 답변에 덧붙여, 다음의 점에 주의해 주세요.sendmail.ini 삭제:

auth_password=this-is-Not-your-Gmail-password

새로운 Google 보안 문제로 인해 이 목적을 위한 응용 프로그램 암호를 만들려면 다음 단계를 수행해야 합니다.

  1. 보안 탭에서 https://accounts.google.com/으로 이동합니다.
  2. 사용 가능한 옵션을 사용하여 2단계 검증을 유효하게 하다
  3. 보안 탭(2단계 검증이 처음 발견된 섹션 아래)으로 돌아가서 App-password를 만듭니다(Select-App 드롭다운 메뉴에서 'Other'를 선택할 수 있습니다).

마지막으로 어플리케이션만 사용하는 경우 PHP 코드를 직접 작성하는 대신 Sendmail을 권장 옵션으로 설정해야 할 수 있습니다.

XAMPP를 관리자로 실행하면 파일 액세스 문제도 해결됩니다.

정의해야 합니다.SMTP서버 및 포트를 지정합니다.라이브 호스트에서 메일을 보내는 것 같은 것만 빼면요.

이것은 이에 관한 유용한 링크입니다.

NB: 포트를 사용하지 마십시오.주의해 주세요.어플리케이션에는Skype는 기본 포트 및 을 사용하여 메일 발송을 금지합니다.

한 시간 넘게 이 일을 해내려고 노력했어요게시된 모든 제안으로 인해 동일한 문제를 겪고 있는 모든 사용자: XAMPP interface에서 Apache를 재시작해야 합니다. XAMPP를 재시작하는 것만으로 문제가 해결되지 않습니다.

XAMPP Localhost에서 메일을 보내려고 여러 가지 방법을 시도했지만 XAMPP가 SSL 인증서를 가지고 있지 않기 때문에 Gmail 또는 유사한 SMTP 서비스 공급자에 의해 이메일 요청이 차단되었습니다.

그리고 로컬 smtp 서버에 MailHog를 사용했는데 실행만 하면 됩니다.localhost: 1025는 smtp 서버용, localhost: 8025는 메일서버용.보낸 전자 메일을 확인할 수 있습니다.

코드는 다음과 같습니다.

    require_once "src/PHPMailer.php";
    require_once "src/SMTP.php";
    require_once "src/Exception.php";

    $mail = new PHPMailer\PHPMailer\PHPMailer();

      //Server settings
    $mail->SMTPDebug = 3;                      // Enable verbose debug output
    $mail->isSMTP();                                            // Send using SMTP
    $mail->Host       = 'localhost';                    // Set the SMTP server to send through
    $mail->Port       = 1025;                                    // TCP port to connect to
    // $mail->Username   = '';                     // SMTP username
    // $mail->Password   = '';                               // SMTP password
    // $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
    // $mail->SMTPSecure = 'tls';         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted

    //Recipients
    $mail->setFrom('testtoo@testto.com', 'Mailer');
    $mail->addAddress('testtoo@webbamail.com', 'Joe User');     // Add a recipient

    // Content
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    if(!$mail->Send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
        echo "Message sent!";
    }

MailHog Github Repository 링크

언급URL : https://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost