Send Mail Using Amazon EC2 Instance
Asked Answered
B

5

11

I am using Amazon EC2 Instance for one of my project, I have installed LAMP on linux server and now while I am trying to send email using simple function it is not sending email also is not giving any error for that.

Things I have done so far.

  • Created SES account.
  • Used simple mail function.
  • Enabled port 25 in security groups.
Biyearly answered 8/11, 2013 at 11:50 Comment(1)
Installing sendmail as https://mcmap.net/q/955054/-send-mail-using-amazon-ec2-instance answered below is much better than using SES I thinkCutright
T
10

Although your problem relates to Sendmail have you tried following Amazons Documentation?

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp-app.html

This uses postfix but it seems like a better alternative and there's help readily available for it.

You also can use SMTP as Amazon SES supports this:

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp.html

I know this doesn't directly answer your question. You might just need to configure the mail settings in php.ini.

Tulipwood answered 8/11, 2013 at 12:15 Comment(2)
thnks buddy, i have installed "POSTFIX", and now it is working fineBiyearly
You might want to accept the answer then if everything has been resolvedTulipwood
E
33

I solved this issue just by installing sendmail in my instance. Just run bellow command in your terminal

sudo apt-get install sendmail

That worked for me

Eric answered 16/7, 2014 at 20:35 Comment(4)
Thanks a ton! This simply works for me without having to use SES!Cutright
I followed their tutorial of using Postfix/SES and it took me a long time to set it up, hours. This tooks seconds!Eleanoraeleanore
Use sudo yum install sendmail if you're on ec2 instanceFermat
Simple and best :) ThanksMezcaline
T
12

If you are using a amazon ec2 ami/linux distro use "sudo yum install sendmail" while in SSH

Tourism answered 1/10, 2014 at 2:16 Comment(1)
For Ubuntu on AWS EC2, use; sudo apt-get install sendmailSacaton
T
10

Although your problem relates to Sendmail have you tried following Amazons Documentation?

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp-app.html

This uses postfix but it seems like a better alternative and there's help readily available for it.

You also can use SMTP as Amazon SES supports this:

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp.html

I know this doesn't directly answer your question. You might just need to configure the mail settings in php.ini.

Tulipwood answered 8/11, 2013 at 12:15 Comment(2)
thnks buddy, i have installed "POSTFIX", and now it is working fineBiyearly
You might want to accept the answer then if everything has been resolvedTulipwood
S
1

If you are using AWS SES you need to make sure you validate the account first:

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html

With the exception of addresses containing labels (see below), you must verify each email address that will be used as a "From" or "Return-Path" address for your messages. The entire email address is case-sensitive. For example, if you verify [email protected], you cannot send emails from [email protected] unless you verify [email protected] also. (Domain verification, however, is case-insensitive. For more information, see Verifying Domains in Amazon SES.)

Until you are granted production access to Amazon SES, you must also verify the email address of every recipient except for the recipients provided by the Amazon SES mailbox simulator. For more information about the mailbox simulator, see Testing Amazon SES Email Sending. For more information about production access, see Requesting Production Access to Amazon SES.

Staggard answered 8/11, 2013 at 12:48 Comment(0)
H
-2

Alternatively, instructions mentioned in the following link can be followed. In this method installing postfix, sendmail or any other mail server is not required.

It uses the PHPMailer class to send email through Amazon SES using the SMTP interface.

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-php.html

It took me a whole day to reach this simpler solution.

Haight answered 3/3, 2021 at 12:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.