Use PHP mail to send via smtp

Does anyone know if you can configure the php mail () command to use only the SMTP server and not the local sendmail? We are having trouble marking emails as spam.

Our server runs RedHat 5 Enterprise.

I am aware of various PHP libraries that act as the SMTP client, but I would prefer to configure PHP so that mail () uses the SMTP server directly.

+3
source share
5 answers

According to this manual page , this is only possible for Windows.

+1
source

Check out these links:

Example:

: , SMTP- mail().

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>
0

, , Linux/Unix "sendmail". , - SMTP-, , . SMTP Windows - , "sendmail" .

sendmail , SMTP. ssmtp ( avialable )

0

sendmail, ! , PHP.

PHP SMTP, !

0

SMTP , PEAR Mail. Net_SMTP SMTP-. . . , .

If you are looking for a replacement for an old function mail(), but which is sent via SMTP instead of PHP by default, you need to write a translator function that sets all the parameters in the correct order and the like. Here is an example of such a script - obviously, you have to change it to match the required parameters: http://tltech.com/info/php-mail-via-smtp/

0
source

Source: https://habr.com/ru/post/1724373/


All Articles