用PHP代码发送电子邮件 [英] Send Email with PHP Code
本文介绍了用PHP代码发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用CKEditor或HTML编写PHP发送的电子邮件。当电子邮件发送时,HTML代码出现在电子邮件中,我知道它,但是头文件已经尝试了巨大而没有工作。
以下是我发送电子邮件的代码。
函数mail_users ($ titulo,$ conteudo){
$ query = mysql_query(SELECT`Email`,`Nome` FROM`utilizadores` WHERE`Newsletter` ='Ativada'); ($ row = mysql_fetch_assoc($ query))!== false){
$ header。=MIME-Version:1.0 \r\\\
;
。
$ header。=Content-Type:text / html; charset = ISO-8859-1 \r\\\
;
email($ row ['Email'],$ titulo,Olá。$ row ['Nome']。,\\\
\\\
。$ conteudo,$ header);
$ div $解析方案
你应该这样做。
- 将标题移至while循环外部。
- 函数应该是
mail()
而不是email()
[除非您为相同的写了封装文件)
- 函数应该是
正确的方法....
$ b $ pre $ 函数mail_users($ titulo,$ conteudo){
$ query = mysql_query(SELECT`Email`,`Nome` FROM`utilizadores` WHERE`Newsletter` ='Ativada');
$ header =MIME-Version:1.0 \r\\\
;
$ header。=Content-Type:text / html; charset = ISO-8859-1 \r\\\
;
while(($ row = mysql_fetch_assoc($ query))!== false){
mail($ row ['Email'],$ titulo,Olá。$ row [ 'Nome']。,\\\
\\\
。$ conteudo,$ header);
}
}
$ query = mysql_query(SELECT`Email`,`Nome` FROM`utilizadores` WHERE`Newsletter` ='Ativada');
$ header =MIME-Version:1.0 \r\\\
;
$ header。=Content-Type:text / html; charset = ISO-8859-1 \r\\\
;
while(($ row = mysql_fetch_assoc($ query))!== false){
mail($ row ['Email'],$ titulo,Olá。$ row [ 'Nome']。,\\\
\\\
。$ conteudo,$ header);
}
}
I'm trying to send an email in PHP that is written with CKEditor, or HTML. When the email is sent the HTML code appears in the email, I know it but the Headers already tried putting immense and none works.
Below is my code to send the email.
function mail_users($titulo, $conteudo){
$query = mysql_query("SELECT `Email`, `Nome` FROM `utilizadores` WHERE `Newsletter` = 'Ativada'");
while (($row = mysql_fetch_assoc($query)) !== false){
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
email($row['Email'], $titulo, "Olá " . $row['Nome'] . ",\n\n" . $conteudo, $header);
}
}
解决方案
You should do this way..
- Move the header outside of the while loop.
- You are doing a mistake in concatenation.
- Function should be
mail()
instead ofemail()
[Unless you have written a wrapper for the same]
The right way....
function mail_users($titulo, $conteudo){
$query = mysql_query("SELECT `Email`, `Nome` FROM `utilizadores` WHERE `Newsletter` = 'Ativada'");
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
while (($row = mysql_fetch_assoc($query)) !== false){
mail($row['Email'], $titulo, "Olá " . $row['Nome'] . ",\n\n" . $conteudo, $header);
}
}
这篇关于用PHP代码发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文