0
votes

I am trying to send an email using the postfix server on amazon EC2 instance.

The command is: sendmail [email protected] FROM:localhost SUBJECT:Welcome this is a test email.... .

However I am getting the following error in the /var/log/maillog file.

the error is:


Jan 13 09:00:37 ip-172-31-32-76 postfix/pickup[26635]: C43AE62D00: uid=222 from=

Jan 13 09:00:37 ip-172-31-32-76 postfix/cleanup[26727]: C43AE62D00: message-id=<20140113090037.C43AE62D00@"HOSTNAME">

Jan 13 09:00:37 ip-172-31-32-76 postfix/qmgr[26636]: C43AE62D00: from=<"MYHOSTNAME">, size=435, nrcpt=1 (queue active)

Jan 13 09:00:37 ip-172-31-32-76 postfix/smtp[26729]: connect to 127.0.0.1[127.0.0.1]:2525: Connection refused

Jan 13 09:00:37 ip-172-31-32-76 postfix/smtp[26729]: C43AE62D00: to=, relay=none, delay=22, delays=22/0.02/0/0, dsn=4.4.1, status=deferred (connect to 127.0.0.1[127.0.0.1]:2525: Connection refused)


I have hidden the details for hostname and the email ID to which I want to send.

please help me out in thus regard.

I have also added the port 25 in the outbound and inbound port in the security groups for my instance.

Regards, Anurag

3

3 Answers

0
votes

I think the other service is running in the same port,

"netstat -tap" run the command and check whether the same port is using for something.

0
votes

connect to 127.0.0.1[127.0.0.1]:2525: Connection refused

Something is preventing Postfix from using this port. (Port 2525 is sometimes being used instead of 587 as an alternative smtp port. )

  1. Verify which ports are listening:

    netstat -tanp | grep LISTEN
    
  2. If you see sendmail (or any other MTA except for Postfix):

    tcp    0   0 127.0.0.1:2525       0.0.0.0:*       LISTEN      1014/sendmail
    

get rid of it:

    service sendmail stop
    yum remove sendmail
  1. Verify settings on the first table row in:

    /etc/postfix/master.cf
    

If it says: smtp inet n - n - - smtpd postfix listens on port 25 and your security group settings make sense. IF the line says 2525 inet n - n - - smtpd you are telling postfix to listen on port 2525 for incoming smtpd connections.

The line that says:

    submission inet n       -       n       -       -       smtpd

does not begin with a comment.

  1. Verify iptables rules, adjust if necessary:

    iptables -L -n
    
0
votes

This could be unrelated but I'm going to post it here because I had a hard time finding the answer to my question. I was able to get outbound email working from a vagrant virtual box by editing my /etc/resolv.conf to use Google's nameserver rather than the 10.0.x.x IP it was set to:

sudo nano /etc/resolv.conf

Change the nameserver IP:

nameserver 8.8.8.8

Then you'll need to restart postfix:

sudo /etc/init.d/postfix restart