2014-01-21 2 views
0

저는 PHP, PHPMyAdmin, Localhost 등을 처음 사용합니다. 현재 내 localhost (내 Ubuntu에 Xampp을 설치했습니다)에서 테스트하고있는 웹 사이트를 작성하고 있습니다. 나는 잘 작동하는 등록 양식을 만들고 싶었지만 (모든 것이 데이터베이스에 저장됩니다), 실제로 어떤 사용자가 계정을 활성화했는지보고 싶습니다.php 등록 후 유효성 확인 이메일을 보내십시오.

그래서 고유 한 코드가 포함 된 유효성 확인 메일을 보내고 싶습니다. 문제는 지금 내가 입력하려고 시도했다는 것입니다 : mail($to, $subject, $message, $headers),하지만 그것이 작동하지 않는 것으로 나타났습니다.

sendmail, postfix, dovecot, telnet 등을 설치하려고했지만 아무 것도 작동하지 않는 것 같아서 좋은 연습을 찾을 수 없었습니다.

우분투 (12.04LTS), xampp (php5.5), 로컬 호스트/phpmyadmin.

누군가가 훌륭한 연습을 알고 있거나이 작업을 수행하는 방법을 알고 있다면 정말 감사하겠습니다.

+0

postfix를 설치하는 튜토리얼 https://help.ubuntu.com/community/Postfix –

+0

cmd-line에 "sendmail [email protected]"를 입력하여 메일 보내기 기능을 사용해보십시오. 그런 다음, 당신의 메시지는 cry + D를 보내서 보내십시오. evrything이 설정되어 있으면 [email protected]로 메일을 보내십시오. –

답변

0

다음은 간단한 자습서로 도움이 될 수 있습니다.

http://sourcelibrary.org/2011/08/29/how-to-set-up-the-php-mail-function-on-a-ubuntu-linux-lamp-server/

는이 라인 php.ini 파일을 업데이트 했습니까?

sendmail_path = "/usr/sbin/sendmail -t -i" 

그런 다음 아파치를 다시 시작하십시오.

+0

php.ini 메일을 이미 업데이트 했으므로 튜토리얼을 따라 갔지만 메일을받지 못했습니다. – user3212257

0

PHPMailer를 사용해 볼 수 있습니다. PHP로 전자 메일을 보내는 강력한 라이브러리입니다.

https://github.com/Synchro/PHPMailer

여기 당신을 위해 하나의 예를 넣을 수 있습니다.

컴퓨터의 경우 PHPMailer를 다운로드하십시오.
둘째, 설치시 PHPMailerAutoload.php가 필요합니다. 필자의 예에서는 phpmailer 디렉토리에있다. 이것은 (phpmailer는) 그래서, 내 응용 프로그램과 같은 디렉토리에 있습니다

<?php 
require 'phpmailer/PHPMailerAutoload.php'; 

//Create a new PHPMailer instance 
$mail = new PHPMailer(); 
//Set who the message is to be sent from 
$mail->setFrom('[email protected]', 'First Last'); 
//Set an alternative reply-to address 
$mail->addReplyTo('[email protected]', 'First Last'); 
//Set who the message is to be sent to 
$mail->addAddress('[email protected]', 'John Doe'); 
//Set the subject line 
$mail->Subject = 'PHPMailer mail() 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('contents.html'), dirname(__FILE__)); 
//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.gif'); 

//send the message, check for errors 
if (!$mail->send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message sent!"; 
} 
?> 

내가 PHPMailer Github에서의에서이 예제를했다 https://github.com/PHPMailer/PHPMailer/blob/master/examples/mail.phps

당신은 또한 (있는 경우) 보내 Gmail 계정을 사용할 수 있습니다 전자 메일 https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps

다른 예제가 있습니다.

수정 방법을 알려주세요. 행운을 비네.

관련 문제