$from = "[email protected]";
$headers = "From:" . $from;
echo mail ("[email protected]" ,"testmailfunction" , "Oj",$headers);
PHP でメールを送信する際に問題が発生しました。次のエラーが発生します: SMTP server response: 530 SMTP authentication is required
。
SMTP を使わずに電子メールを送信して検証できるという印象を持っていました。このメールはおそらくフィルタリングされると思いますが、それは今のところ問題ではありません。
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = [email protected]
これはファイル内の設定ですphp.ini
。SMTP はどのように設定すればよいですか? 検証を必要としない SMTP サーバーはありますか? それとも自分でサーバーを設定する必要がありますか?
ベストアンサー1
SMTP Auth を必要とするサーバー経由で電子メールを送信する場合は、SMTP Auth を指定し、ホスト、ユーザー名、パスワード (および、デフォルトのポート 25 でない場合はポートも) を設定する必要があります。
たとえば、私は通常、次のような設定で PHPMailer を使用します。
$mail = new PHPMailer();
// Settings
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "mail.example.com"; // SMTP server example
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "username"; // SMTP account username example
$mail->Password = "password"; // SMTP account password example
// Content
$mail->setFrom('[email protected]');
$mail->addAddress('[email protected]');
$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';
$mail->send();
PHPMailer の詳細については、こちらをご覧ください:参考: