Simple PHP Mail feature not working on Amazon EC2 server

See this code

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?> 

what is the problem in this code. It does not work on Amazon Linux server

thanks

+4
source share
5 answers

I had the same issue as when sending email using php mail(). The mail sending installation solved it for me.

sudo apt-get install sendmail
+8
source

The Amazon server allows you to send sendmail functions using localhost. Please uncomment the mail configuration in php.ini.

I already did this and worked great.

+1
source

? , phpmailer... .

. http://phpmailer.worxware.com/

+1

-, PHP EC2 , . , : EC2 - PHP -

@Charles :

(: ), Amazon EC2 . , .

, Amazon , EC2, EC2. API PHP , SwiftMailer ().

- , , , , SwiftMailer, , SendGrid

* : SO php mail EC2

: Simple Email Service, SendGrid. . smtp. , [ , ). - ssl:// , SMTP error: 530 5.7.0 Must issue a STARTTLS command first.. CakePHP EC2, .

0

Just follow the instructions below (Tested for ubuntu 10x EC2)

sudo apt-get install php-pear   // Install php-pear if not installed 

sudo pear install mail  

sudo pear install Net_SMTP

sudo pear install Auth_SASL

sudo pear install mail_mime

sudo apt-get install postfix

sudo service apache2 restart

Enjoy it!

-1
source

All Articles