Search code examples
smtpzend-mail

Zend_Mail is sent perfectly, but takes ages to arrive to gmail


I'm trying to send mails through gmail smtp. The process works fine and all, but for some reason, after altering the sending structure, the mails take AGES to arrive to gmail. I can wait 20 minutes or more for one of the system sent mails to drop in, but it is still displayed as (20 minutes ago) in the inbox. Any clues on to what I'm doing wrong?

$config = Zend_Registry::get('Zend_Config_Ini');
$tr = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config->mail->toArray());

Then, in a foreach for mails to be sent:

$mail = new Zend_Mail('UTF-8');
$mail->setType(Zend_Mime::MULTIPART_RELATED);
if (isset($pendingMail['senderMail']))
    $mail->setFrom($pendingMail['senderMail'], $pendingMail['senderfName'] . " " . $pendingMail['senderlName']);
$mail->addTo($pendingMail['receiverMail']);
$mail->setSubject($pendingMail['mailSubject']);
$mail->setBodyHtml(urldecode($pendingMail['mailContent']));

$mail->send();

$this->update(array('sent' => 1), 'idMail = \'' . $pendingMail['idMail'] . '\'');

Is this related to the MULTIPART_RELATED type or what am I missing around here? To reiterate: The mails work, but they show up in the gmail inbox about 20 minutes after arriving to gmail. Halp?


Solution

  • It might not be your code, but your SMTP server that as some cache system. Your code seems ok to me.