古いチュートリアルを勉強していて、以下に示す問題に直面しています。助けてください。これは簡単だと思いますが、理解できない問題があります。
codeigniter を使用してメールを送信中にエラーが発生した場合、以下にエラーが表示されます。
220 mx.google.com ESMTP f4sm2807502pbg.56
hello: 250-mx.google.com at your service, [119.30.39.69]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH
250-ENHANCEDSTATUSCODES
250 PIPELINING
from: 250 2.1.0 OK f4sm2807502pbg.56
to: 553-5.1.2 We weren't able to find the recipient domain. Please check for any
553-5.1.2 spelling errors, and make sure you didn't enter any spaces, periods,
553 5.1.2 or other punctuation after the recipient's email address. f4sm2807502pbg.56
The following SMTP error was encountered: 553-5.1.2 We weren't able to find the recipient domain. Please check for any 553-5.1.2 spelling errors, and make sure you didn't enter any spaces, periods, 553 5.1.2 or other punctuation after the recipient's email address. f4sm2807502pbg.56
data: 503 5.5.1 RCPT first. f4sm2807502pbg.56
The following SMTP error was encountered: 503 5.5.1 RCPT first. f4sm2807502pbg.56
502 5.5.1 Unrecognized command. f4sm2807502pbg.56
The following SMTP error was encountered: 502 5.5.1 Unrecognized command. f4sm2807502pbg.56
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Wed, 11 Apr 2012 12:46:40 +0000
From: "myname"
Return-Path:
To: $email
Subject: =?utf-8?Q?This_is_an_email_test?=
Reply-To: "m.methun@gmail.com"
X-Sender: m.methun@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <4f857d304b4f7@gmail.com>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="B_ATC_4f857d304b520"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ATC_4f857d304b520
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Its working. Great!
--B_ATC_4f857d304b520
Content-type: text/plain; name="yourinfo.txt"
Content-Disposition: attachment;
Content-Transfer-Encoding: base64
ZmZmZmZmZmY=
--B_ATC_4f857d304b520--
私のプログラムは以下のとおりです。
メール.php
<?php
class Email extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index(){
$this->load->view('newsletter');
}
function send()
{
$this->load->library('form_validation');
//field name, error message, validation rules
$this->form_validation->set_rules('name', 'Name', 'trim|required');
$this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email');
if($this->form_validation->run() == FALSE)
{ // this is from validation..that works
$this->load->view('newsletter');
}
else
{
// validation has passed. now send email
$name = $this->input->post('name');
$email = $this->input->post('email');
$this->load->library('email');
$this->email->set_newline("\r\n");
$this->email->from('m.methun@gmail.com', 'myname');
$this->email->to('$email');
$this->email->subject('This is an email test');
$this->email->message('Its working. Great!');
// attachment of file...in sending mail
$path = $this->config->item('server_root');
$file = $path . '/ci/attachments/yourinfo.txt';
$this->email->attach($file);
//end
if($this->email->send())
{
echo ' mail send ';
}
else
{
show_error($this->email->print_debugger());
}
}
}
}
?>
ニュースレター.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type = "text/css">
label{ display: block; };
</style>
</head>
<body>
<div id ="newsletter_form">
<?php echo form_open('email/send'); ?>
<?php
$name_data = array(
'name'=>'name',
'id' => 'name',
'value' => set_value('name')
);
?>
<?php
//three ways of taking input..from form
?>
<p><label for = "name" > Name:</label>
<?php echo form_input($name_data); ?> </p>
<p><label for = "name" >Email Address:</label>
<input type ="text" name="email" id="email"
value = "<?php echo set_value('email'); ?>">
</p>
<p> <?php echo form_submit('submit','Submit'); ?> </p>
<?php
// end of taking inputs...
?>
<?php echo form_close(); ?>
<?php echo validation_errors('<p class ="error" >'); ?>
</div>
</body>
</html>
config/email.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config['protocol'] = 'smtp';
$config['smtp_host']='ssl://smtp.googlemail.com';
$config['smtp_port']=465;
$config['smtp_user']='m.methun@gmail.com';
$config['smtp_pass']='methun123';
?>
問題は単純だと思いますが、修正できません。