Impact of using PHP mail ()

I have a project where I send an email using the built-in PHP () function, I just send one email for a small amount of HTML and very limited CSS (two tables and a bit of CSS in my head for styling), but the server seems to be , does it very slowly (so much so that the page to which the administrator sends the message often from time to time)

So my question is: does mail () put a high load on the server (not sure if this is the right term), or is it just that the server I'm using is garbage?

Should I consider projects like http://pear.php.net/package/Mail for this kind of thing?

EDIT:

Here is the code in question:

$query = "SELECT email FROM $a_table WHERE id='$Id'"; $result = mysql_query($query) or die("Query failed: ".mysql_error()); $mail_to = mysql_fetch_row($result); $mail_to = $mail_to[0]; // multiple recipients $to = $mail_to; // subject $subject = 'notification'; // message $message = '<html> <head> <title>title goes here</title> <style type="text/css"> table { border: 1px solid #000;} table tr th { background-color: #d8d8d8; border-bottom: 1px solid #000} table tr th, table tr td { padding: 4px; text-align: center; } </style> </head> <body> <h1>header goes here</h1> <table cellspacing="0"> <tr> <th>th1</th><td>'.$var.'</td> </tr> <tr> <th>th2</th><td>'.$var2.'</td> </tr> <tr> <th>th3</th><td>'.$var3.'</td> </tr> </table> <p>&nbsp;</p> <table cellspacing="0"> <tr> <th colspan="13">Key</th> </tr> <tr> <th>G</th> <th>I</th> <th>L</th> <th>M</th> <th>N</th> <th>O</th> <th>Q</th> <th>R</th> <th>S</th> <th>V</th> <th>W</th> <th>C</th> <th>?</th> </tr> <tr> <td>G</td> <td>I</td> <td>L</td> <td>M</td> <td>U</td> <td>O</td> <td>Q</td> <td>R</td> <td>S</td> <td>V</td> <td>W</td> <td>C</td> <td>R</td> </tr> </table> </body> </html> // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: admin< admin@admin.com >' . "\r\n"; // might need to get rid of this soon // Mail it mail($to, $subject, $message, $headers); } 
0
source share
1 answer

The mail() function is usually very fast. I used it in the past for mass mail systems and processed hundreds of letters per second.

I would recommend checking how your system is configured to send emails. mail() usually uses your sendmail install (or postfix) system. You should consider checking logs to see if there are any problems.

+1
source

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


All Articles