Home >Backend Development >PHP Tutorial >maison martin margiela phpmail class send mail function code
With the phpmail class, you don't have to worry. This is a class written by a foreigner, so we just "use it". The following is a function written based on the send() method in this class:
Copy code The code is as follows:
function send_mail ($title,$content,$from,$to,$charset='gbk ',$attachment ='')
{
include '/class/PHPMail.class.php';
header('Content-Type: text/html; charset='.$charset);
$mail = new PHPMailer( );
$mail->CharSet = $charset; //Set to use gb2312 Chinese encoding
$mail->IsSMTP(); //Set to use SMTP to send emails
$mail->Host = "smtp.qq .com"; //Set the address of the mail server
$mail->Port = 25; //Set the port of the mail server, the default is 25
$mail->From = $from; //Set the sender's port Email address
$mail->FromName = ""; //Set the sender's name
$mail->SMTPAuth = true; //Set whether SMTP requires password verification, true means it is required
$mail->Username = $from; //Set the email address for sending emails
$mail->Password = ""; //Set the password for the email address
$mail->Subject = $title; //Set the title of the email
$mail-> ;AltBody = "text/html"; // optional, comment out and test
$mail->Body = $content; //Set the email content
$mail->IsHTML(true); //Set whether the content is HTML type
$mail->WordWrap = 50; //Set the number of characters per line
$mail->AddReplyTo("Address", "Name"); //Set the address of the reply recipient
$mail ->AddAddress($to,"Star Model Training"); //Set the recipient address
if ($attachment != '') //Set the attachment
{
$mail->AddAttachment($attachment, $attachment);
}
if(!$mail->Send())
{
return false;
} else {
return true;
}
}
The above introduces the maison martin margiela phpmail class mail sending function code, including the content of maison martin margiela. I hope it will be helpful to friends who are interested in PHP tutorials.