I Just moved from a test enviroment to a new Webhost, and now my application throws errors when I try to send a mail. I am using CakePHP and the CakeMail function to send this email.
This is the last part of the Error Message:
Could not send email.
Error: An Internal Error Has Occurred.
Stack Trace
CORE/Cake/Network/Email/MailTransport.php line 46 → MailTransport->_mail(string, string, string, string, null)
CORE/Cake/Network/Email/CakeEmail.php line 1065 → MailTransport->send(CakeEmail)
APP/Controller/UsersController.php line 204 → CakeEmail->send(string)
[internal function] → UsersController->add()
Temporarily, you can reproduce the error by registering (just put anything in, I don't mind) on this webpage: http://eevent.ch/index.php/users/add
My Code looks like this:
$emailstring = 'emailstring';
$Email = new CakeEmail();
$Email->emailFormat('both');
$Email->from(array('info@eevent.ch' => 'info'));
$Email->to(array( username => usermail));
$Email->subject(__('Registrierung auf Eevent.ch'));
$Email->send($emailstring);
I am Assuming that my code is correct as it works just fine on the test server.
From searching this error on StackOverflow I have checked a few things. I set the $email->from with an array. I checked my phpinfo, it does include sendmail_from me@localhost.com me@localhost.com sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
Is it possible that me not setting a Header produces the Error?
Thanks in advance.
In this line
$Email->to(array( username => usermail));
there should be string or variables passed to an array. Like here:
$Email->to(array( 'username' => $usermail));
And did you configured email.php in /app/config/mail.php ?
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.