Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > alt.comp.lang.php > #94
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Newsgroups | alt.comp.lang.php |
| Subject | Re: How to cath mail error |
| Date | 2022-05-30 15:40 +0200 |
| Message-ID | <jfjvq9FtbjuU1@mid.individual.net> (permalink) |
| References | <6294c1cf$0$463$65785112@news.neostrada.pl> |
On 30/05/2022 15.08, Jakub wrote:
> I have this code to sand email:
>
>
> function sendEmail($to, $title, &$text) {
> $from = 'jakub@jakubowo.net';
> $subject = $title;
>
> $w = '<html><head><meta http-equiv="content-type"
> content="text/xhtml; charset=utf-8"></head>
> <body
> style="background-color:#ffffff;color:#000000;margin-top:30px;margin-left:30px;padding:10px;"><hr><br>'
>
> . $text . '<hr><br><p><a href="mailto:'
> . $from . '">' . $from . '</a></p></body></html>';
>
> $he = 'MIME-Version: 1.0' . PHP_EOL . 'Content-type: text/html;
> charset=utf-8 ' . PHP_EOL
> . 'From: admin Search. <' . $from . '>' . PHP_EOL
> . 'Content-Transfer-Encoding: base64' . PHP_EOL;
>
> $w = chunk_split(base64_encode($w));
> imap_mail($to, $subject, $w, $he);
> }
>
>
> how to catch this error
imap_mail will just return true or false, all you can do on the php side
would be
if(imap_mail($to, $subject, $w, $he)) {
echo "Email was received by mail server";
} else {
echo "Failed to send email, check mail server logs";
}
> Warning: imap_mail(): Failed to connect to mailserver at "localhost"
> port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use
> ini_set()
Had this been imap errors, then you had the imap_errors() and
imap_last_error() to use.
Your error is a php configuration error and you should in such case use
ini_get() to see that proper values has been set for smtp and smtp_port.
Also you need to ensure you have the right services up and running.
--
//Aho
Back to alt.comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar
How to cath mail error Jakub <jak74@interia.pl> - 2022-05-30 14:08 +0100 Re: How to cath mail error "J.O. Aho" <user@example.net> - 2022-05-30 15:40 +0200 Re: How to cath mail error K <yyyyyeeeee00000@writeme.com> - 2023-03-11 07:54 -0800
csiph-web