AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / unix / Perguntas / 571210
Accepted
OtagoHarbour
OtagoHarbour
Asked: 2020-03-05 17:57:56 +0800 CST2020-03-05 17:57:56 +0800 CST 2020-03-05 17:57:56 +0800 CST

Email enviado, do script PHP, não aparecendo

  • 772

Estou executando um site em duas instâncias do AWS EC2 executando o Ubuntu. Estou usando LAMP. O código PHP a seguir costumava enviar e-mails com sucesso para alertar sobre atividades suspeitas, mas parou de fazê-lo em janeiro de 2020.

<?php
    // Function to email notification of suspicious entry
    function emailPossibleSQLInjectionNotification($ipAddress, $emailAddress, $field, $entry, $time)
    {
            $to = "[email protected]";
            $subject = "Suspicious activity";
            $message = "Dear Sir,\n\n" .
                    "The following invalid entry was entered for " . $field . ".\n\n" .
                    $field . ": " .  $entry . "\n" .
                    "Client IP address" . ": " .  $ipAddress . "\n" .
                    "Client email address" . ": " .  $emailAddress . "\n" .
                    "Time" . ": " .  $time . "\n\n" .
                    "Have a wonderful day!\nWeb Site Name.\n";
            $from = "[email protected]";
            $headers = "From:" . $from;
            mail($to,$subject,$message,$headers);
    }
?>

A seguir

cat /var/log/mail.log

retorna

Mar  5 00:30:41 ip-10-0-1-76 sm-mta[30561]: 02339OqL008906: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=1+21:21:17, xdelay=00:00:00, mailer=esmtp, pri=19290583, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Mar  5 00:39:01 ip-10-0-1-76 sendmail[30620]: 0250d12h030620: from=root, size=550, class=0, nrcpts=1, msgid=<[email protected]>, bodytype=8BITMIME, relay=root@localhost
Mar  5 00:39:01 ip-10-0-1-76 sm-mta[30621]: 0250d14c030621: from=<[email protected]>, size=848, class=0, nrcpts=1, msgid=<[email protected]>, bodytype=7BIT, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Mar  5 00:39:01 ip-10-0-1-76 sendmail[30620]: 0250d12h030620: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30550, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (0250d14c030621 Message accepted for delivery)
Mar  5 00:39:01 ip-10-0-1-76 sm-mta[30622]: 0250d14c030621: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31084, dsn=2.0.0, stat=Sent
 Mar  5 00:40:41 ip-10-0-1-76 sm-mta[30576]: 023MRjPq024050: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=1+02:12:56, xdelay=00:10:36, mailer=esmtp, pri=7140592, relay=alt4.gmail-smtp-in.l.google.com. [172.217.218.26], dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Mar  5 00:40:41 ip-10-0-1-76 sm-mta[30576]: 023H1exj022946: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=1+07:39:01, xdelay=00:00:00, mailer=esmtp, pri=9660592, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Mar  5 00:40:41 ip-10-0-1-76 sm-mta[30576]: 02339OqL008906: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=1+21:31:17, xdelay=00:00:00, mailer=esmtp, pri=19380583, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Mar  5 00:50:41 ip-10-0-1-76 sm-mta[30646]: 024KKwfi029723: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=04:29:43, xdelay=00:10:36, mailer=esmtp, pri=1290584, relay=alt4.gmail-smtp-in.l.google.com. [172.217.218.26], dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Mar  5 00:50:41 ip-10-0-1-76 sm-mta[30646]: 023H1exj022946: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=1+07:49:01, xdelay=00:00:00, mailer=esmtp, pri=9750592, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Mar  5 00:50:41 ip-10-0-1-76 sm-mta[30646]: 02339OqL008906: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=1+21:41:17, xdelay=00:00:00, mailer=esmtp, pri=19470583, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Mar  5 01:00:41 ip-10-0-1-76 sm-mta[30660]: 023MRjPq024050: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=1+02:32:56, xdelay=00:10:36, mailer=esmtp, pri=7230592, relay=alt4.gmail-smtp-in.l.google.com. [172.217.218.26], dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Mar  5 01:00:41 ip-10-0-1-76 sm-mta[30660]: 023H1exj022946: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=1+07:59:01, xdelay=00:00:00, mailer=esmtp, pri=9840592, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Mar  5 01:00:41 ip-10-0-1-76 sm-mta[30660]: 02339OqL008906: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=1+21:51:17, xdelay=00:00:00, mailer=esmtp, pri=19560583, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
Mar  5 01:07:30 ip-10-0-1-76 sendmail[30700]: 02517Uj6030700: from=www-data, size=342, class=0, nrcpts=1, msgid=<[email protected]>, relay=www-data@localhost
Mar  5 01:07:30 ip-10-0-1-76 sm-mta[30701]: 02517UA4030701: from=<[email protected]>, size=583, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Mar  5 01:07:30 ip-10-0-1-76 sendmail[30700]: 02517Uj6030700: [email protected], ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30342, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (02517UA4030701 Message accepted for delivery)
Mar  5 01:09:01 ip-10-0-1-76 sendmail[30846]: 025191nX030846: from=root, size=550, class=0, nrcpts=1, msgid=<[email protected]>, bodytype=8BITMIME, relay=root@localhost
Mar  5 01:09:01 ip-10-0-1-76 sm-mta[30847]: 025191Bc030847: from=<[email protected]>, size=848, class=0, nrcpts=1, msgid=<[email protected]>, bodytype=7BIT, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Mar  5 01:09:01 ip-10-0-1-76 sendmail[30846]: 025191nX030846: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30550, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (025191Bc030847 Message accepted for delivery)
Mar  5 01:09:01 ip-10-0-1-76 sm-mta[30848]: 025191Bc030847: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31084, dsn=2.0.0, stat=Sent

A seguir

$ sudo netstat -ntlp | grep sendmail

retorna

tcp        0      0 127.0.0.1:587           0.0.0.0:*               LISTEN      
1337/sendmail: MTA:
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      
 1337/sendmail: MTA:

Um ISP não seria um problema, pois estou executando o aplicativo de uma instância AWS EC2 na nuvem.

eu percebi isso

df -i

retorna

Filesystem     Inodes  IUsed  IFree IUse% Mounted on
udev           124432    357 124075    1% /dev
tmpfs          126762    472 126290    1% /run
/dev/xvda1     917504 607710 309794   67% /
tmpfs          126762      1 126761    1% /dev/shm
tmpfs          126762      6 126756    1% /run/lock
tmpfs          126762     16 126746    1% /sys/fs/cgroup
tmpfs          126762      4 126758    1% /run/user/1000

então não é um problema com inodes.

 ps -e | grep sendmail

retorna

  1337 ?        00:00:08 sendmail-mta
  4109 ?        00:00:00 sendmail-mta
  4320 ?        00:00:00 sendmail-mta

O e-mail simplesmente não aparece, nem mesmo na pasta de spam.

Editar:

eu também tentei

ubuntu@ip-10-0-1-76:~$ sendmail [email protected]
Test
ubuntu@ip-10-0-1-76:~$

Ainda não aparece nenhum e-mail na minha conta do Gmail.

ubuntu email
  • 1 1 respostas
  • 570 Views

1 respostas

  • Voted
  1. Best Answer
    OtagoHarbour
    2020-03-25T15:01:24+08:002020-03-25T15:01:24+08:00

    Foi devido a uma mudança que a AWS fez. Corrigi o problema da seguinte forma.

    1. Instalado e configurado o Postfix conforme descrito aqui .
    2. Filtro de instância do AWS EC2 editado para permitir SMTP na porta 587.
    3. Editado /etc/postfix/main.cf para incluir relayhost = [email-smtp.us-east-1.amazonaws.com]:587.
    4. sudo postfix recarregar
    • 0

relate perguntas

  • traçar gráfico 2D com pontos de um arquivo

  • Como faço para verificar se estou usando 9.9.9.9 para DNS?

  • Instale várias distribuições Linux em paralelo

  • O OpenVPN auto-compilado não inicia a partir do systemd

  • Recebendo e-mail em um novo Debian fresco

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Possível firmware ausente /lib/firmware/i915/* para o módulo i915

    • 3 respostas
  • Marko Smith

    Falha ao buscar o repositório de backports jessie

    • 4 respostas
  • Marko Smith

    Como exportar uma chave privada GPG e uma chave pública para um arquivo

    • 4 respostas
  • Marko Smith

    Como podemos executar um comando armazenado em uma variável?

    • 5 respostas
  • Marko Smith

    Como configurar o systemd-resolved e o systemd-networkd para usar o servidor DNS local para resolver domínios locais e o servidor DNS remoto para domínios remotos?

    • 3 respostas
  • Marko Smith

    apt-get update error no Kali Linux após a atualização do dist [duplicado]

    • 2 respostas
  • Marko Smith

    Como ver as últimas linhas x do log de serviço systemctl

    • 5 respostas
  • Marko Smith

    Nano - pule para o final do arquivo

    • 8 respostas
  • Marko Smith

    erro grub: você precisa carregar o kernel primeiro

    • 4 respostas
  • Marko Smith

    Como baixar o pacote não instalá-lo com o comando apt-get?

    • 7 respostas
  • Martin Hope
    user12345 Falha ao buscar o repositório de backports jessie 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl Por que a maioria dos exemplos do systemd contém WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky Como exportar uma chave privada GPG e uma chave pública para um arquivo 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll status systemctl mostra: "Estado: degradado" 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim Como podemos executar um comando armazenado em uma variável? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S Por que /dev/null é um arquivo? Por que sua função não é implementada como um programa simples? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 Como ver as últimas linhas x do log de serviço systemctl 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - pule para o final do arquivo 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla Por que verdadeiro e falso são tão grandes? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis Substitua a string em um arquivo de texto enorme (70 GB), uma linha 2017-12-30 06:58:33 +0800 CST

Hot tag

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve