php.ini & SMTP =-사용자 이름과 비밀번호를 어떻게 전달합니까?
My ISP
계정을 사용하려면 발신 SMTP
메일에 대한 사용자 이름과 비밀번호를 보내야합니다 .
어떻게받을 수 있나요 PHP
실행할 때이를 사용하는 파일 것은 단지 서버에 대한 항목이 들어 와 .php.mail()?
php.ini
(SMTP= )
From: (sendmail_from= )
PHP mail()
명령은 인증을 지원하지 않습니다. 옵션 :
- PHPMailer - 자습서
- PEAR - 자습서
- 사용자 정의 함수-노트 섹션에서 다양한 솔루션을 참조하십시오 : http://php.net/manual/en/ref.mail.php
php.ini 파일에 다음 세부 사항을 적용합니다. 잘 작동합니다.
SMTP = smtp.example.com
smtp_port = 25
username = info@example.com
password = yourmailpassord
sendmail_from = info@example.com
이러한 세부 정보는 Outlook 설정과 동일합니다.
Windows 용 가짜 sendmail을 사용 하여 메일을 보냅니다.
sendmail
에서 이름이 지정된 폴더를 만듭니다C:\wamp\
.- 이러한 4 파일의 압축을 풉니 다
sendmail
: 폴더sendmail.exe
,libeay32.dll
,ssleay32.dll
와sendmail.ini
. - 그런 다음 구성하십시오
C:\wamp\sendmail\sendmail.ini
.
smtp_server=smtp.gmail.com smtp_port=465 auth_username=user@gmail.com auth_password=your_password
위의 내용은 Gmail 계정에서 작동합니다. 그런 다음 php.ini를 구성합니다.
sendmail_path = "C : \ wamp \ sendmail \ sendmail.exe -t"
이제 Apache를 다시 시작하면 기본적으로해야 할 일이 전부입니다.
PHP 는 mail-command에 대한 인증을 가지고 있습니다!
다음은 WAMPSERVER (windows, php 5.2.17)에서 나를 위해 일하고 있습니다.
php.ini
[mail function]
; For Win32 only.
SMTP = mail.yourserver.com
smtp_port = 25
auth_username = smtp-username
auth_password = smtp-password
sendmail_from = you@yourserver.com
PEAR가 필요하지 않기 때문에 PHPMailer 도구를 선호합니다 . 그러나 어느 쪽이든 오해가 있습니다. SMTP 사용자 및 암호에 대한 PHP 서버 전체 설정을 원하지 않습니다. 앱별 (또는 페이지 별) 설정이어야합니다. 다른 PHP 페이지에서 동일한 계정을 사용하려면 settings.php 파일의 종류에 추가하십시오.
하루 종일 일한 끝에 마침내 해결책을 찾았습니다. WAMP를 사용하여 Windows XP에서 보내는 방법은 다음과 같습니다.
- Google의 SMTP 서버를 사용하십시오. 아마도 계정이 필요할 것입니다.
- Fake Sendmail을 다운로드하여 설치 합니다. 방금 다운로드하고 압축을 풀고 WAMP 폴더에 넣었습니다.
- 테스트 PHP 파일을 만듭니다. 아래를 참조하십시오.
<?php $message = "test message body"; $result = mail('recipient@some-domain.com', 'message subject', $message); echo "result: $result"; ?>
- php.ini 파일과 sendmail.ini 파일을 업데이트합니다 (sendmail.ini는 sendmail 폴더에 있음).
- 방금 만든 sendmail 폴더에서 error.log 파일이 작동하지 않는 경우 확인합니다.
참고:
- http://www.geekzone.co.nz/tonyhughes/599
- http://www.joshstauffer.com/send-test-emails-with-wampserver/
- Postfix를 설치합니다 (Sendmail 호환).
/etc/postfix/main.cf
읽기 위해 편집 :
#Relay config
relayhost = smtp.server.net
smtp_use_tls=yes
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_sasl_security_options = noanonymous
- 작성
/etc/postfix/sasl_passwd
, 입력 :
smtp.server.net username:password
유형 #
/usr/sbin/postmap sasl_passwd
그런 다음 다음을 실행하십시오.
service postfix reload
이제 PHP는 sendmail -t -i
명령을 사용하여 평소와 같이 메일을 실행하고 Postfix는 메일을 가로 채서 사용자가 제공 한 SMTP 서버로 전달합니다.
Mail PEAR 패키지의 Mail :: factory를 사용하십시오. 예.
이 답변은 오래되고 감가 상각되었습니다. 모범 사례 ..
composer require phpmailer/phpmailer
sendmail.php 파일의 다음 파일에는 다음이 필요합니다.
# use namespace
use PHPMailer\PHPMailer\PHPMailer;
# require php mailer
require_once "../vendor/autoload.php";
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->From = "from@yourdomain.com";
$mail->FromName = "Full Name";
//To address and name
$mail->addAddress("recepient1@example.com", "Recepient Name");
$mail->addAddress("recepient1@example.com"); //Recipient name is optional
//Address to which recipient will reply
$mail->addReplyTo("reply@yourdomain.com", "Reply");
//CC and BCC
$mail->addCC("cc@example.com");
$mail->addBCC("bcc@example.com");
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
원하는대로 구성 할 수 있습니다 ..
Considering one answer in this question, In PHP 4 the PEAR Mail package is typically already installed, and this really simple tutorial shows you the few lines of code that you need to add to your php file http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
- Install the latest hMailServer. "Run hMailServer Administrator" in the last step.
- Connect to "localhost".
- "Add domain..."
- Set "127.0.0.1." as the "Domain", click "Save".
- "Settings" > "Protocols" > "SMTP" > "Delivery of e-mail"
- Set "localhost" as the "Local host name", provide your data in the "SMTP Relayer" section, click "Save".
- "Settings" > "Advanced" > "IP Ranges" > "My Computer"
- Disable the "External to external e-mail addresses" checkbox in the "Require SMTP authentication" group.
- If you have modified php.ini, rewrite these 3 values:
"SMTP = localhost",
"smtp_port = 25",
"; sendmail_path = ".
Credit: How to configure WAMP (localhost) to send email using Gmail?
참고URL : https://stackoverflow.com/questions/112190/php-ini-smtp-how-do-you-pass-username-password
'Development Tip' 카테고리의 다른 글
EC2에서 인스턴스를 삭제하는 방법은 무엇입니까? (0) | 2020.11.20 |
---|---|
Docker 명령 실패 (Windows) (0) | 2020.11.20 |
JavaScript가 문자열과 숫자 사이의 더하기 및 빼기 연산자를 다르게 처리하는 이유는 무엇입니까? (0) | 2020.11.19 |
Gradle 프로젝트 새로 고침에 실패했습니다. (0) | 2020.11.19 |
Redux를 React 앱에 언제 추가해야합니까? (0) | 2020.11.19 |