0

I am running into a problem with zend mail sending functionality.

I have a functionality where we have set up some cron jobs and those cron jobs processes some php script and then sends a mail. Actually mails are going fine, but sometimes it is getting dropped into spam directory. After some research I have found that the return-path of mail body is causing problem. Since the mail sending script us as a root, so the return-path is root@domain.com and I want change it to support@domain.com

Is there any way I can achieve that.

Note: I did try to add that in headers, but it is not working.

chandresh_cool
  • 11,753
  • 3
  • 30
  • 45
  • Did you try https://www.sendmail.com/sm/open_source/docs/m4/features.html#genericstable or you do not have enough permissions? – Cheery Oct 09 '14 at 06:12

1 Answers1

0

It's return-path not reply-to... There's no such thing as reply-path :)

There are lots of parameters for being marked as spam and I'm not sure it's because of return-path only. You have to fix it though and you can try by altering the headers while sending:

    $mail = new Zend_Mail();
    $mail->addTo($this->email, $this->name)
        ->setFrom($message->from_email, $message->from_name)
        ->setSubject($message->subject)
        ->setBodyHtml($message->getHtmlEmailContent($subscriber))
        ->setBodyText($message->getTextEmailContent($subscriber))
        ->setReturnPath($settings->get('return_path'))

However SMTP servers might override this (gmail definitely does). Just open the email in raw and see if your header is there and if it's overriden or not.

If mails are marked as spam in your test account randomly you might want to check the contents and subject of your email. SPF records for your SMTP domain is important too.

See https://www.campaignmonitor.com/blog/post/1971/what-are-some-good-methods-for and http://mailchimp.com/resources/guides/how-to-avoid-spam-filters/ for some details.

See this answer for the explanation of reply-to and return-path.

Community
  • 1
  • 1
madpoet
  • 1,023
  • 11
  • 28
  • I already have tried setReturnPath and also addHeader. Zend documentation itself say setReturnPath won't work. More can be found here http://framework.zend.com/manual/1.11/en/zend.mail.additional-headers.html. – chandresh_cool Oct 09 '14 at 06:45
  • Hmm I see, you're using sendmail. It works for Zend_Mail_Transport_Smtp. Have you tried `new Zend_Mail_Transport_Sendmail('-freturn_to_me@example.com')` as instructed? – madpoet Oct 09 '14 at 06:54