0

I am using following code to send email from my magento store but i am not able to sent any email

<?php
echo "start mail";
echo "<br>";
ini_set('memory_limit', '500M');
ini_set('max_execution_time', 0);
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
require_once 'app/Mage.php';
umask(0);
Mage::app();
try {
    $post['name'] = 'vaibhav';
    $post['email'] = 'vaibhavahalpara@gmail.com';
    $post['telephone'] = '123456789';
    $postObject = new Varien_Object();
    $postObject->setData($post);
    $mailTemplate = Mage::getModel('core/email_template');
    $mailTemplate = Mage::getModel('core/email_template');
    $mailTemplate->setDesignConfig(array('area' => 'frontend'))
                    ->setReplyTo('vaibhavahalpara@gmail.com')
                    ->sendTransactional(
                        Mage::getStoreConfig('contacts/email/email_template'),
                        Mage::getStoreConfig('contacts/email/sender_email_identity'),
                        'vaibhavahalpara@gmail.com',
                        null,
                        array('data' => $postObject)
                    );
    if (!$mailTemplate->getSentSuccess()) {
        throw new Exception();
    }
    echo "sent";
} catch (Exception $e) {
    echo "string11465";
    echo $e->getMessage();
}

Php mail script is working

$msg = "First line of text\nSecond line of text";
$msg = wordwrap($msg,70);
mail("vaibhavahalpara@gmail.com","My subject",$msg); 

so i debugging code to Zend_Mail_Transport_Sendmail::_sendMail() following code is not able to send mail but $result is 1

$result = mail(
    $this->recipients,
    $this->_mail->getSubject(),
    $this->body,
    $this->header
);
echo $result;

when i tried to remove $this->header variable email sending working but body is not look good

previously we used Mandrill email this is happen after removing Mandrill module

now we are using amazonses service

  • What exception is displayed? I think you miss some variables on sendTransactional method call / replyTo email and also contact email template is waiting for some variables (check template for this). – Jonathan Ribas Mar 23 '17 at 8:02
  • question updated i am not missing anything just typo here – Vaibhav Ahalpara Mar 23 '17 at 8:43
  • Have you solved your problem? – Jonathan Ribas Mar 25 '17 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.