localhost SMTP からメールを送信する方法 (Wamp、Xampp などを使用)? PHPmail()
はネイティブで動作しないようです。
誰でも指示を与えることができますか?
localhost SMTP からメールを送信する方法 (Wamp、Xampp などを使用)? PHPmail()
はネイティブで動作しないようです。
誰でも指示を与えることができますか?
インストール後、wampserver からメールを適切に送信するには、次の構成が必要です。
1) When you first open hMailServer Administrator, you need to add a new domain.
2) Click on the "Add Domain ..." button at the Welcome page.
3) Under the domain text field, enter your computer's IP, in this case it should be 127.0.0.1.
4) Click on the Save button.
5) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab
6) Enter "localhost" in the localhost name field.
7) Click on the Save button.
別のコンピュータの FROM アドレスを使用してメールを送信する必要がある場合は、外部アカウントから外部アカウントへの配信を許可する必要があります。これを行うには、次の手順に従います。
1) Go to Settings>Advanced>IP Ranges and double click on "My Computer" which should have IP address of 127.0.0.1
2) Check the Allow Deliveries from External to External accounts checkbox.
3) Save settings using Save button.
(ただし、Windows Live/Hotmail は、ほとんどの家庭用コンピューターが使用している動的 IP からのすべての電子メールを拒否しています。回避策は、Gmail アカウントを使用することです)。
1) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab
2) Enter "smtp.gmail.com" in the Remote Host name field.
3) Enter "465" as the port number
4) Check "Server requires authentication"
5) Enter gmail address in the Username
6) Enter gmail password in the password
7) Check "Use SSL"
(注: Fromフィールドは gmail では機能しません)
*ps 一部の人にとっては、以下のすべてのチェックを外す必要があるかもしれませんrequire SMTP authentication
:
SendMail のインストールを使用できます。
これらの方法のいずれかを使用します。
ローカルの xampp、wamp に問題がある場合は、このライブラリを使用してメールを送信できます...
class.phpmailer.php,class.smtp.php メール関数が呼び出すファイルにこのコードを記述します
include('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "your email ID";
$mail->Password = "your email password";
$fromname = "From Name in Email";
$To = trim($email,"\r\n");
$tContent = '';
$tContent .="<table width='550px' colspan='2' cellpadding='4'>
<tr><td align='center'><img src='imgpath' width='100' height='100'></td></tr>
<tr><td height='20'> </td></tr>
<tr>
<td>
<table cellspacing='1' cellpadding='1' width='100%' height='100%'>
<tr><td align='center'><h2>YOUR TEXT<h2></td></tr/>
<tr><td> </td></tr>
<tr><td align='center'>Name: ".trim(NAME,"\r\n")."</td></tr>
<tr><td align='center'>ABCD TEXT: ".$abcd."</td></tr>
<tr><td> </td></tr>
</table>
</td>
</tr>
</table>";
$mail->From = "From email";
$mail->FromName = $fromname;
$mail->Subject = "Your Details.";
$mail->Body = $tContent;
$mail->AddAddress($To);
$mail->set('X-Priority', '1'); //Priority 1 = High, 3 = Normal, 5 = low
$mail->Send();
Afwe Wefの回答に続いて次のようなエラーが発生した場合
Warning: mail() [<a href='function.mail'>function.mail</a>]: SMTP server response:
550 The address is not valid. in c:\wamp\www\email.php
php.iniに移動します
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = valideaccount@gmail.com
sendmail_fromの前に、hMailserver の設定に使用した電子メール ID として、valideaccount@gmail.com を入力します。
あなたの問題は解決されます。
Windows 8のWamp server2.2(Apache 2.2.22、php 5.3.13)でテスト済み
次のエラーも発生する場合
"APPLICATION" 6364 "2014-03-24 13:13:33.979" "SMTPDeliverer - Message 2: Relaying to host smtp.gmail.com."
"APPLICATION" 6364 "2014-03-24 13:13:34.415" "SMTPDeliverer - Message 2: Message could not be delivered. Scheduling it for later delivery in 60 minutes."
"APPLICATION" 6364 "2014-03-24 13:13:34.430" "SMTPDeliverer - Message 2: Message delivery thread completed."
ポートを 25 から 465 に変更するのを忘れている可能性があります。