Welcome Guest, Not a member yet? Register   Sign In
SMTP server problem
#1

(This post was last modified: 03-29-2025, 04:27 AM by pippuccio76.)

HI , i have a bad server..
 When i try to send multiple mail (this is only for testing, i must send 3 different email simoultanously ) : 

Code:
    public function test_invio_3_mail()
    {
        $email_to = '[email protected]';
        $oggetto_mail = 'Test Email';
        $message = '<p>This is a test email sent to multiple recipients.</p>';

        $result = $this->invia_mail_tratta($email_to, $oggetto_mail, $message);

        if ($result === 'inviata') {
            echo 'Emails sent successfully to ' . $email_to;
        } else {
            echo 'Failed to send emails: ' . $result;
        }


        $email_to = '[email protected]';
        $oggetto_mail = 'Test Email';
        $message = '<p>This is a test email sent to multiple recipients.</p>';

        $result = $this->invia_mail_tratta($email_to, $oggetto_mail, $message);

        if ($result === 'inviata') {
            echo 'Emails sent successfully to ' . $email_to;
        } else {
            echo 'Failed to send emails: ' . $result;
        }



        $email_to = '[email protected]';
        $oggetto_mail = 'Test Email';
        $message = '<p>This is a test email sent to multiple recipients.</p>';

        $result = $this->invia_mail_tratta($email_to, $oggetto_mail, $message);

        if ($result === 'inviata') {
            echo 'Emails sent successfully to ' . $email_to;
        } else {
            echo 'Failed to send emails: ' . $result;
        }
    }

this is invia_mail_tratta
Code:
    private function invia_mail_tratta($email_to,$oggetto_mail,$message){


        $email = \Config\Services::email();


        //$dati_azienda_model = new Dati_aziendaModel();

        //$dati_azienda = $dati_azienda_model->find(1);

        $email->setMailType('html');
        $email->setFrom('[email protected]');
        $email->setTo($email_to);
        //$email->cc('[email protected]');
        //$email->bcc('[email protected]');

        $email->setSubject($oggetto_mail);



        $email->setMessage($message);

        if ($email->send(true)) {
           
            $email->clear(true);

            return 'inviata';
         
        }else{


            return $email->printDebugger();
        }

    }
this is the error :
Code:
Failed to send emails: 220 hpt01.web.l1.armada.it ESMTP Postfix
hello: 250-hpt01.web.l1.armada.it
250-PIPELINING
250-SIZE 52428800
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 CHUNKING
from: 250 2.1.0 Ok
to: 250 2.1.5 Ok
data: 354 End data with .

quit: 250 2.0.0 Ok: queued as 3F5BDCC695
The following SMTP error was encountered: 250 2.0.0 Ok: queued as 3F5BDCC695
The following SMTP error was encountered:
Unable to send email using SMTP. Your server might not be configured to send mail using this method.
Date: Sat, 29 Mar 2025 12:14:13 +0100
From: <[email protected]>
Return-Path: <[email protected]>
To: [email protected]
Subject: =?UTF-8?Q?Test=20Email?=
Reply-To: <[email protected]>
User-Agent: CodeIgniter
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0


Content-Type: multipart/alternative; boundary="B_ALT_67e7d6052e97f9.15655388"

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_67e7d6052e97f9.15655388
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is a test email sent to multiple recipients.


--B_ALT_67e7d6052e97f9.15655388
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p>This is a test email sent to multiple recipients.</p>

--B_ALT_67e7d6052e97f9.15655388--
Failed to send emails: 220 hpt01.web.l1.armada.it ESMTP Postfix
hello: 250-hpt01.web.l1.armada.it
250-PIPELINING
250-SIZE 52428800
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 CHUNKING
from: 250 2.1.0 Ok
to: 250 2.1.5 Ok
data: 354 End data with .

quit: 250 2.0.0 Ok: queued as 3F5BDCC695
The following SMTP error was encountered: 250 2.0.0 Ok: queued as 3F5BDCC695
The following SMTP error was encountered:
Unable to send email using SMTP. Your server might not be configured to send mail using this method.
Failed to send AUTH LOGIN command. Error: 221 2.0.0 Bye
Unable to send email using SMTP. Your server might not be configured to send mail using this method.
Date: Sat, 29 Mar 2025 12:14:13 +0100
From: <[email protected]>
Return-Path: <[email protected]>
To: [email protected]
Subject: =?UTF-8?Q?Test=20Email?=
Reply-To: <[email protected]>
User-Agent: CodeIgniter
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0


Content-Type: multipart/alternative; boundary="B_ALT_67e7d60ed09ef8.63370120"

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_67e7d60ed09ef8.63370120
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is a test email sent to multiple recipients.


--B_ALT_67e7d60ed09ef8.63370120
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p>This is a test email sent to multiple recipients.</p>

--B_ALT_67e7d60ed09ef8.63370120--
Failed to send emails: 220 hpt01.web.l1.armada.it ESMTP Postfix
hello: 250-hpt01.web.l1.armada.it
250-PIPELINING
250-SIZE 52428800
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5 PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 CHUNKING
from: 250 2.1.0 Ok
to: 250 2.1.5 Ok
data: 354 End data with .

quit: 250 2.0.0 Ok: queued as 3F5BDCC695
The following SMTP error was encountered: 250 2.0.0 Ok: queued as 3F5BDCC695
The following SMTP error was encountered:
Unable to send email using SMTP. Your server might not be configured to send mail using this method.
Failed to send AUTH LOGIN command. Error: 221 2.0.0 Bye
Unable to send email using SMTP. Your server might not be configured to send mail using this method.
Unable to send email using SMTP. Your server might not be configured to send mail using this method.
Date: Sat, 29 Mar 2025 12:14:13 +0100
From: <[email protected]>
Return-Path: <[email protected]>
To: [email protected]
Subject: =?UTF-8?Q?Test=20Email?=
Reply-To: <[email protected]>
User-Agent: CodeIgniter
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0


Content-Type: multipart/alternative; boundary="B_ALT_67e7d60ed0ba07.08117340"

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_67e7d60ed0ba07.08117340
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is a test email sent to multiple recipients.


--B_ALT_67e7d60ed0ba07.08117340
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p>This is a test email sent to multiple recipients.</p>

--B_ALT_67e7d60ed0ba07.08117340--


It send only first email
Reply
#2

Hi pippuccio76.
If the code works for sending the first email you could try adding a pause (sleep(5)) between sends in case the SMTP has some restriction.
After sending an email, you are calling $email->clear(true);. This is good practice, but ensure that you are not clearing the email object too soon. You might want to check if the email object is still valid before sending the next email.
Regards.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB