M
M
masterwen2020-05-02 11:38:11
PHP
masterwen, 2020-05-02 11:38:11

How to insert html email template into code?

There is a code for automatically sending a letter from the site. And how to insert html template into this code. To make writing beautiful.

function RecoveryPassword($user, $pass, $mail){
  
  
  
  
  
  
    $text.= "Данные для входа в личный кабинет пользователя: <BR />";
    $text.= "<b>Логин:</b> {$user}<BR />";
    $text.= "<b>Пароль:</b> {$pass}<BR />";
    $text.= "Ссылка для входа в кабинет: <a href='http://".$this->Hosts."/signin'>http://".$this->Hosts."/signin</a>";
    $subject = "Восстановление забытого пароля в системе \"".$this->Hosts."\"";
    
    return $this->SendMail($mail, $subject, $text);
    
  }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
ThunderCat, 2020-05-02
@ThunderCat

In general, judging by $this->Hoststhe first you have "type oop", since it seems to be objects, but it seems that the codestyle of the curve and in the model (?) / controller (?) some kind of horseradish forgot html ... therefore it would be correct create a layout and a view for a letter, change the current object's View object's layout to a mail one, and render the view into a variable. But it will be easier for you like this:
1) Find a template
2)

function RecoveryPassword($user, $pass, $mail){
ob_start();?>
код шаблона, со вставленными в нужные места значениями через <?=$value?>
<?php
$text = ob_get_clean();
$subject = "Восстановление забытого пароля в системе \"".$this->Hosts."\"";
return $this->SendMail($mail, $subject, $text);
}

B
bibebub, 2020-05-02
@bibebub

Look at the code of the object on which you call SendMail. Somewhere there must be an option to insert html. Most likely they use the standard php mail function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question