有没有可能的方法,从表格到邮件发送脚本插入数据?我制作了这个简单的脚本,但它不起作用。如何混合这两个代码?
$result = mysql_query("SELECT * FROM tablename WHERE ID =1" ) or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo ''. $row['maillist'] .''; }
$to = 'here must be maillist row';
$subject = 'my subject:';
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$message = 'html content with img src tag';
mail($to, $subject, $message, $headers);
我的第二个问题是:如果我使用的是bcc,那么gmail或其他邮件服务会显示包含所有标签的完整邮件代码,但不会显示图片。那么,有没有办法解决这个问题?
我的第三个问题是:如果我将图片插入到邮件中(观看代码),则该邮件会显示在垃圾邮件中,但如果我只使用基本文本,则表示正常。怎么解决?
我将非常感谢任何答案和帮助!
答案 0 :(得分:0)
$q = "SELECT email FROM table WHERE id = '" . $id . "'";
$r = mysql_query($q) or die(mysql_error().'<br />'.$q);
$d = mysql_fetch_assoc($r);
$to = $d['email']:
$subject = 'my subject:';
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$message = 'html content with img src tag';
mail($to, $subject, $message, $headers);
如果您想向几个人发送电子邮件:
$subject = 'my subject:';
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$message = 'html content with img src tag';
$q = "SELECT email FROM table WHERE id = IN (" . $array_ids . ")";
$r = mysql_query($q) or die(mysql_error().'<br />'.$q);
while($row = mysql_fetch_assoc($r)) {
$to = $row['email']:
mail($to, $subject, $message, $headers);
}
对于垃圾邮件问题,我会说尝试设置这样的标题
$headers .= 'Content-type: image/jpeg' . "\r\n";