2016-10-25 10 views
-1
<?php 
$to = '[email protected]'; 
$subject = 'this is my first php mail'; 
$message = 'iam akhil from yagna tech , thanks'; 
$headers = 'From:<[email protected]>'."\r\n". 
'Reply-To:[email protected]'."\r\n".'X-Mailer:PHP/'. PHPversion(); 
$res=mail($to,$subject,$message,$headers); 
if($res) 
{ 
echo 'email sent successfully'; 
} 
else { 
echo 'failure email'; 
} 
?> 

警告:メール():SMTPサーバーの応答:530 5.7.0は、最初にSTARTTLSコマンドを発行する必要があります。 zh13sm33324633pab.4 - Cでgsmtp:\ xamppの\ htdocsに\学ぶ\ライン上mail1.php 9 障害メール警告:C: xamppの htdocsに学ぶ 9行目の障害の電子メールのmail1.php

+3

をし、あなたの質問はありますか? –

+0

警告:mail():SMTPサーバーの応答:530 5.7.0最初にSTARTTLSコマンドを発行する必要があります。 zh13sm33324633pab.4 - gsmtp in C:\ xampp \ htdocs \ learn \ mail1.php 9行目 失敗メール –

+0

コードの実行時に警告が表示されますか?私のミスはどこで受けましたか? –

答えて

0

お使いのSMTPサーバは、SSLやTLSプロトコルに基づいた安全な接続を期待しています。 SSL/TLS形式の電子メールを作成して送信できる電子メールクラスの使用を検討する必要があります。私はここでphpmailerの(https://github.com/PHPMailer/PHPMailer) を使用

はSSL使用して、メールのオブジェクトを生成するコードのサンプルです:

require __DIR__.'/PHPMailerAutoload.php'; 

/** 
* Create the PHPMailer object 
* @return PHPMailer 
*/ 
function PHPMailerFunction_mailer(){ 
    $mailer = new PHPMailer; 
    //$mailer->SMTPDebug = 3; // Enable verbose debug output 
    $mailer->Timeout = 60; // Default 300 (5 min) 
    $mailer->isSMTP(); // Set mailer to use SMTP 
    $mailer->Host = 'smtps.servername.com'; // Specify main and backup SMTP servers 
    $mailer->SMTPAuth = true; // Enable SMTP authentication 
    $mailer->Username = '[email protected]'; // SMTP username 
    $mailer->Password = 'AbCdEfGh0123'; // SMTP password 
    $mailer->SMTPSecure = 'ssl'; // Enable SSL/TLS encryption 
    $mailer->Port = 465; // TCP port to connect to 
    return $mailer; 
} 
+0

をチェックしたことがありますか?iam a begginerプズ助け? –

+0

https://github.com/PHPMailer/PHPMailer#a-simple-example スクリプトをダウンロードしてインストールします。そして、サンプルコードを使用してみてください。 – Thomas

関連する問題