473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

sending html email using php script

Ann
Hi,

I am trying to send a html email from a php script. This script emails
a common information to all the members in the database. The only
problem is I cannot specify colors, hyperlinks etc..Html tags like
<h1></h1>, <br/>, <b> etc works though..

Could any one tell me what i might be doing wrong? Any help will be
greatly appreciated.

Thanks,
Ann

Code:
function mail_it($content, $subject, $email, $recipient) {
global $attachment_chunk, $attachment_name, $attachment_type,
$attachment_sent, $bcc;
global $db;
global $msgbody;

$ob = "----=_OuterBoundary_000";
$ib = "----=_InnerBoundery_001";

$sql_result = mysql_query("SELECT * FROM contacts", $db);
echo "<br/><b>Emails sent to:</b><br/>";

while($rs = mysql_fetch_array($sql_result))
{
$message = "";
$headers = "";
$recip = $rs["Email"];
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: ".$email."\r\n";
$headers .= "To: ".$recip."\r\n";
$headers .= "Reply-To: ".$email."\r\n";
if ($bcc) $headers .= "Bcc: ".$bcc."\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-Mailer: Formmail".VERSION."\r\n";
$headers .= "Content-Type:
multipart/mixed;\r\n\tboundary=\"".$ob."\"\r\n";

$ToName = $rs["Salutation"]."".$rs["FirstName"]."
".$rs["LastName"];
$content = "Hello ".$ToName.",<br/><br/>";
$content .= $msgbody;
$content .=" <br/><br/>";
$content .="Thank you.";
$content .=" <br/><br/><br/>";
$content .="<small><font color='blue'>Please send an email to <a
href='mailto:ab*@def.com&subject='Re:Email Notifications' to get more
information.</font></small>";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n--".$ob."\r\n";
$message .= "Content-Type:
multipart/alternative;\r\n\tboundary=\"".$ib."\"\r\n\r\n";
$message .= "\r\n--".$ib."\r\n";
//$message .= "Content-Type:
text/plain;\r\n\tcharset=\"iso-8859-1\"\r\n";
$message .= "Content-Type:
text/html;\r\n\tcharset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding:
quoted-printable\r\n\r\n";
$message .= $content."\r\n\r\n";
$message .= "\r\n--".$ib."--\r\n";
if ($attachment_name && !$attachment_sent) {
$message .= "\r\n--".$ob."\r\n";
$message .= "Content-Type:
$attachment_type;\r\n\tname=\"".$attachment_name." \"\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition:
attachment;\r\n\tfilename=\"".$attachment_name."\" \r\n\r\n";
$message .= $attachment_chunk;
$message .= "\r\n\r\n";
$attachment_sent = 1;
}
$message .= "\r\n--".$ob."--\r\n";

mail($recip, $subject, $message, $headers);
}

}
Jul 17 '05 #1
4 4318
On 2004-10-04, Ann <ns****@yahoo.com> wrote:
Hi,

I am trying to send a html email from a php script. This script emails
a common information to all the members in the database. The only
problem is I cannot specify colors, hyperlinks etc..Html tags like
<h1></h1>, <br/>, <b> etc works though..

Could any one tell me what i might be doing wrong? Any help will be
greatly appreciated.


No one likes HTML mails.
Your php knows that.

SCNR :)

Mail is Mail, not Web.

If you want your users to view Webpages send them a link.

And: HTML mails are often placed higher in spam rankings,
especially when not send correctly. So there's a high chance your
receivers will never read that, because their spam filters catch
it.

--
Marco Dieckhoff
icq# 22243433
GPG Key 0x1A6C95BA -- http://www.frankonia-brunonia.de/keys
Jul 17 '05 #2
Ann a écrit :
Hi,

I am trying to send a html email from a php script. This script emails
a common information to all the members in the database. The only
problem is I cannot specify colors, hyperlinks etc..Html tags like
<h1></h1>, <br/>, <b> etc works though..

Could any one tell me what i might be doing wrong? Any help will be
greatly appreciated.

Thanks,
Ann

Code:
function mail_it($content, $subject, $email, $recipient) {
global $attachment_chunk, $attachment_name, $attachment_type,
$attachment_sent, $bcc;
global $db;
global $msgbody;

$ob = "----=_OuterBoundary_000";
$ib = "----=_InnerBoundery_001";

$sql_result = mysql_query("SELECT * FROM contacts", $db);
echo "<br/><b>Emails sent to:</b><br/>";

while($rs = mysql_fetch_array($sql_result))
{
$message = "";
$headers = "";
$recip = $rs["Email"];
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: ".$email."\r\n";
$headers .= "To: ".$recip."\r\n";
$headers .= "Reply-To: ".$email."\r\n";
if ($bcc) $headers .= "Bcc: ".$bcc."\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-Mailer: Formmail".VERSION."\r\n";
$headers .= "Content-Type:
multipart/mixed;\r\n\tboundary=\"".$ob."\"\r\n";

$ToName = $rs["Salutation"]."".$rs["FirstName"]."
".$rs["LastName"];
$content = "Hello ".$ToName.",<br/><br/>";
$content .= $msgbody;
$content .=" <br/><br/>";
$content .="Thank you.";
$content .=" <br/><br/><br/>";
$content .="<small><font color='blue'>Please send an email to <a
href='mailto:ab*@def.com&subject='Re:Email Notifications' to get more
information.</font></small>";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n--".$ob."\r\n";
$message .= "Content-Type:
multipart/alternative;\r\n\tboundary=\"".$ib."\"\r\n\r\n";
$message .= "\r\n--".$ib."\r\n";
//$message .= "Content-Type:
text/plain;\r\n\tcharset=\"iso-8859-1\"\r\n";
$message .= "Content-Type:
text/html;\r\n\tcharset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding:
quoted-printable\r\n\r\n";
$message .= $content."\r\n\r\n";
$message .= "\r\n--".$ib."--\r\n";
if ($attachment_name && !$attachment_sent) {
$message .= "\r\n--".$ob."\r\n";
$message .= "Content-Type:
$attachment_type;\r\n\tname=\"".$attachment_name." \"\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition:
attachment;\r\n\tfilename=\"".$attachment_name."\" \r\n\r\n";
$message .= $attachment_chunk;
$message .= "\r\n\r\n";
$attachment_sent = 1;
}
$message .= "\r\n--".$ob."--\r\n";

mail($recip, $subject, $message, $headers);
}

}

Use php.classmailer ; it 's a nice class
Jul 17 '05 #3
> No one likes HTML mails.
Your php knows that.

SCNR :)

Mail is Mail, not Web.

If you want your users to view Webpages send them a link.

And: HTML mails are often placed higher in spam rankings,
especially when not send correctly. So there's a high chance your
receivers will never read that, because their spam filters catch
it.


Wrong day of the week for a Sermon buddy --

--Wil
Jul 17 '05 #4
la*******@hotmail.com wrote:
No one likes HTML mails.
Your php knows that.

Mail is Mail, not Web.

If you want your users to view Webpages send them a link.

And: HTML mails are often placed higher in spam rankings,
especially when not send correctly. So there's a high chance your
receivers will never read that, because their spam filters catch
it.


Wrong day of the week for a Sermon buddy --


<obligatory>
- I agree with that guy about HTML emails, but understand that sometimes you
don't have a choice
- Single quotes are usually preferable for PHP strings, as PHP doesn't have to
search them for variables
- Though most browsers parse them okay, you really should use double quotes for
HTML attributes
- *cough*CSS*cough*
</obligatory>

$content .="<small><font color='blue'>Please send an email to <a
href='mailto:ab*@def.com&subject='Re:Email Notifications' to get more
information.</font></small>";

^^^^ this line is suspicious. Unless my NG reader mangled the mailto (which is
entirely possible), you don't have a closing </A> tag, you have a '&' instead of
'?' for the query string, you have a space and a single quote in your subject,
you didn't close your opening A tag with a '>' or even the proper quote
I'd try this:
$content .='<small><font color="blue">Please send an email to <a
href="mailto:ab*@def.com?subject='.urlencode('Re:E mail Notifications').'">some
address</a> to get more information.</font></small>';

If that doesn't fix it, try viewing source and copying the HTML from the emails
you receive and run it through the w3c html validator (somewhere at w3c.org).

Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bruce | last post by:
Has anyone tried sending web pages containing javascript to another user also using Outlook Express? Mine don't work on the other end - although I'm not sure if this is because they don't have...
4
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text...
2
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends -...
6
by: Eduardo Rosa | last post by:
Somebody knows how I queue email using .Net? thanks a lot
1
by: robbiesmith79 | last post by:
Just so this is out there on the web, I battled the past 24 hours about this. Background info... I developed a ecommerce website in PHP 4 on a shared linux hosting plan from GoDaddy and had the...
4
by: Rajendran | last post by:
I want to send mail through PHP using the MS Exchange server. My php.ini file looks like this (for the MAIL functions) ------- ; For Win32 only. SMTP = exchgserver.test.com smtp_port = 25 ;...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
2
by: lstanikmas | last post by:
Hi, I'm validating a form with this ASP but receiving some blank email responses; does anyone see anything wrong with it?: function isFormVarExcluded(thisForm, strToCheck) { var strExcludeVars...
3
by: virtualweb | last post by:
Hello: I need to send a bit of HTML and Javascrpt on the body of an email from my perl script in order to have the recipient get a link that will openup a new window with a PopUp. For some...
9
by: neovantage | last post by:
hey geeks, I have a small mail script which will cause a PHP script to send a receipt upon clicking the submit button, by an HTML mail. This mail contains special characters, namely 'å', 'ä' and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.