Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在运行Ubuntu的ec2实例上未发送电子邮件_Php_Codeigniter_Email_Amazon Ec2_Smtp - Fatal编程技术网

Php 在运行Ubuntu的ec2实例上未发送电子邮件

Php 在运行Ubuntu的ec2实例上未发送电子邮件,php,codeigniter,email,amazon-ec2,smtp,Php,Codeigniter,Email,Amazon Ec2,Smtp,我有以下用于发送电子邮件的代码。这在MAMP上运行良好;但不是在灯上 $config = [ 'crlf' => "\r\n", 'mailtype' => 'html', 'newline' => "\r\n", 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtpout.secureserver.net', 'smtp_pass' => 'password',

我有以下用于发送电子邮件的代码。这在MAMP上运行良好;但不是在灯上

$config = [
    'crlf' => "\r\n",
    'mailtype' => 'html',
    'newline' => "\r\n",
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtpout.secureserver.net',
    'smtp_pass' => 'password',
    'smtp_port' => 465,
    'smtp_user' => 'username',
    'wordwrap' => true,
];
$this->load->library('email', $config);

// Send the email
$this->email->from('email@domain.com', 'Email Name');
$this->email->to('myemail@gmail.com');
$this->email->subject('Subject');
$this->email->message('Message');
$this->email->set_newline("\r\n");
var_dump($this->email->send());

false
var\u dump
调用返回。已安装OpenSSL。我检查了此实例的安全组设置,所有出站流量都已启用。

正如我之前建议的,我添加了一个在Amazon EC2上使用phpMail的示例。(工作/测试良好)

当你使用普通邮件(aws)时,你必须付费。及

控制器

require_once('./phpmailer/class.phpmailer.php'); # Files attached below
require_once('./phpmailer/class.smtp.php');

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth   = true;
$mail->SMTPSecure = "tls";
$mail->Host       = "smtp.gmail.com"; 
$mail->Port       = 587;  
$mail->Username   = "someMailAddress@gmail.com";
$mail->Password   = "password";

$to = ('to@mail.com');
$subject = 'This is and test mail from PHPMailer';

$message = 'Hi';
$message .= 'this is an mail body';

$mail->SetFrom( 'info@stackoverflow.com' , 'Stack OverFlow' );
$mail->AddAddress( $to , 'Abdulla Nilam' );
$mail->Subject = $subject;
$mail->MsgHTML( $message );
$sendEmail = $mail->Send();

if( $sendEmail == true )
{
    $this->session->set_flashdata('success', 'It was sent ....');
    redirect('contact');
}
else
{
    $this->session->set_flashdata('error', 'Nah :/ something wrong');
    redirect('contact');
}

您是否有权访问邮件服务器日志,如果有,您能否显示日志中的错误?我的邮件日志没有显示任何相关内容。我不确定是否需要安装postfix或sendmail或两者。请尝试使用它进行调试nothing@LanceEC2或本地设备上的不工作方式??