Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How catch mail error

12 views
Skip to first unread message

Jakub

unread,
May 30, 2022, 9:05:15 AM5/30/22
to
I have this code to sand email:


function sendEmail($to, $title, &$text) {
$from = 'ja...@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

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()

thank for answers

Jakub


Arnold Ziffel

unread,
Jun 2, 2023, 3:42:51 PM6/2/23
to
Jakub <ja...@interia.pl> wrote:

> I have this code to sand email:

This is polska grupa, so you can pisać po polsku.

> function sendEmail($to, $title, &$text) {
> $from = 'ja...@jakubowo.net';

Podanie swojego maila w takiej formie na Usenecie to może nie być
najlepszy pomysł :) Choć może już nawet harvestery tu wyzdychały.

> 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()

Uruchamiasz ten skrypt na Windows? Bo, z tego co widzę w dokumentacji,
serwer SMTP jest używany tylko na Windows.

Musisz ustawić serwer SMTP w php.ini (globalnie) lub przez ini_set
(lokalnie dla skryptu), tak jak jest napisane. Teraz jest ustawiony na
localhost, a wygląda na to, że na localhoście nie słucha żaden serwer
smtp (przynajmniej nie na standardowym porcie 25).

MX dla jakubowo.net to mail.jakubowo.net. Wychodzący serwer może być inny,
ale pewnie jest ten sam, więc spróbuj ustawić:

ini_set('SMTP', 'mail.jakubowo.net');

--
Przychodzi mrówka do krawca i mówi:
- Jest nitka?
- Jest!
- Cale dwa cm proszę!
- Zapakować???
- Nie! Powieszę się na miejscu!
0 new messages