简体   繁体   中英

Why I am getting 500 Internal Server Error while sending an email using Zend Framework 1?

I am getting 500 Internal Server Error while sending email using Zend Framework 1 and code I have mentioned below.

$transport = new Zend_Mail_Transport_Sendmail();
Zend_Loader::loadClass('Zend_Mail');
$mail = new Zend_Mail();
$mail->setFrom('someone@gmail.com', 'Name');
$mail->addTo('someother@gmail.com','Aaaaaa');
$mail->setSubject('Testing ');
$mail->setBodyText('Welcome');
$mail->send($transport);

And I am getting error while executing the on the line send method.

So please help me.

Please do the following to get more informations about the error:

[...]

try {
    $mail->send($transport);
}
catch(Zend_Exception $e) {
    die($e->getMessage());
}

[...]

Please post it here...

There are many problems that can produce a 500 server error!

Sorry I have just seen your errors!

THIS IS WRONG SYNTAX!

$transport = new Zend_Mail_Transport_Sendmail();
Zend_Loader::loadClass('Zend_Mail');
$mail = new Zend_Mail();
$mail->setFrom('someone@gmail.com', 'Name');
$mail->addTo('someother@gmail.com','Aaaaaa');
$mail->setSubject('Testing ');
$mail->setBodyText('Welcome');
$mail->send($transport);

THIS IS CORRECT!

$transport = new Zend_Mail_Transport_Sendmail('no-reply@mydomain.com');

//you need to set the transport adapter via abstract method!
Zend_Mail::setDefaultTransport($transport);

$mail = new Zend_Mail();
$mail->setFrom('someone@gmail.com', 'Name');
$mail->addTo('someother@gmail.com','Aaaaaa');
$mail->setSubject('Testing ');
$mail->setBodyText('Welcome');
$mail->send(); //no parameters here!

More informations... http://framework.zend.com/manual/1.12/en/zend.mail.introduction.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM