Answer the question
In order to leave comments, you need to log in
How to fix the send mail function?
Hello. Such a problem. The freelancer wrote some functionality on the site, among them the function of sending mail (service messages to users). As it turned out now, for some reason mail worked through his own domain. And 4 days ago it stopped working, it turned out that the domain of this freelancer died a long time. There is no connection with him. He disappeared as soon as he did (unfinished) the project.
I have given the full listing of the function below. Question: what was worked out in this line and what should be placed there now in order to work again? Help, friends.
curl_setopt($curl, CURLOPT_URL, 'http://green.alpachini.ru/send_mail.php');
function send_mail($email, $subject, $msg, $file='')
{
$boundary = "--" . md5(uniqid(time()));
$multipart = "--$boundary\n";
$multipart .= "Content-Type: text/html; charset=utf-8\n";
$multipart .= "Content-Transfer-Encoding: Quot-Printed\n\n";
$multipart .= "$msg\n\n";
if(is_array($file)) {
foreach ($file as $key => $value) {
$fp = fopen($value, "r");
$ffile = fread($fp, filesize($value));
$message_part .= "--$boundary\n";
$message_part .= "Content-Type: application/octet-stream\n";
$message_part .= "Content-Transfer-Encoding: base64\n";
$message_part .= "Content-Disposition: attachment; filename=\"".basename($value)."\"\n\n";
$message_part .= chunk_split(base64_encode($ffile)) . "\n";
}
$multipart .= $message_part . "--$boundary--\n";
}
$db=new connect_db();
if($db->state=="connected") {
$id_zayav=$id_zayav*1;
$sql="SELECT email_from FROM settings WHERE id=1";
foreach ($db->dbo->query($sql) as $row){
$email_from=$row[0];
}
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://green.alpachini.ru/send_mail.php');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, "to=$email&tema=".urlencode($subject)."&text=".urlencode($multipart)."&[email protected]&boundary=$boundary");
$out = curl_exec($curl);
curl_close($curl);
}
Answer the question
In order to leave comments, you need to log in
Do not be lazy, rewrite to PHPMailer and you will not know worries.
Well, let's just say that it won't work to fix it, you need to rewrite the piece where the actual "sending mail" is (in fact, an appeal to a third-party mail sending service). You can write a piece where mail will be sent from your server, either use the standard mail () or connect php mailer.
Question: what was worked out in this line and what should be placed there now in order to work again?This line was the initialization of the connection to the remote server on which the mail sending script was running, since now this domain is not responding - the whole piece that was responsible for sending data there does not work, well, nothing is being done on the server there, respectively)
Well, as you already wrote above, that sending occurs through a file that lies on a third-party service, and the one ( http://green.alpachini.ru) has run out of hosting.
In fact, in the condition if(is_array($file)) { ....
You are already collecting the contents of the letter.
If in a hurry, you can try to remove the $curl section of code
AND call the standard mail ().
For example:
// код вашей функции
mail($email, $subject, $multipart);
/*
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://green.alpachini.ru/send_mail.php');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, "to=$email&tema=".urlencode($subject)."&text=".urlencode($multipart)."&[email protected]&boundary=$boundary");
$out = curl_exec($curl);
curl_close($curl);
*/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question