MAIL (Message/Body) problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

MAIL (Message/Body) problem

Post by madhu »

Dear All,

Am facing a small problem.Please help me.

Am doing a task in that am trying to send mails.

In that if i type any link in the textarea of message/body , after sending mail, the link is not activating.

is there any way to enable the hyperlink while using mail() function??

Waiting for your valuable replies....

Thanks and regards
MADHU
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Just add anchor tags around the link, e.g. <a href="http://mysite.com/asdf.php">my link</a>
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

Dear All,

This is the code am using to send mail.

Now the problem is when i sent a mail with HTML content like(http://mail.yahoo.com) , then after sending mail, am not able to recognise as a link.

Before using mail() function, am getting that $message (which contains the content) as link.

But when i sent a mail using mail() function , am not getting that link.

May be problem is with Content-type: text/html.

Other than this link, remaining any HTML tags am able to recognise.

Please guide me where i did mistake...

Code: Select all

$headers  = "MIME-Version: 1.0\r\n";
   $headers .= "Content-type: text/html; charset=ISO-8859-1;\r\n";
   //$headers .= "Content-type: text/plain; charset=ISO-8859-1;\r\n";

             if(mail($toid, $subject, $message, $from.$headers))
                {
                 echo "<div align=\"center\"><strong>Mail sent successfully.....</strong></div>";
                }
Waiting for your valuable replies....

Thanks and regards
MADHU
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

$from.$headers
Where's $from and how is it defined? I'm going to guess it's breaking your headers.
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

Code: Select all

$from = "From: $fromid<$fromtext>\r\n";
$fromid -- name of the person from which mail is going to send
$fromtext --- mailid of the person from which mail is going to send.
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

i checked by replacing $from.$headers by $headers, then also it is not working
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Hmm...

Try

Code: Select all

$headers  = "MIME-Version: 1.0\r\n";
   $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
Changed:

Content-type --> Content-Type
Charset value quoted with ".."
Charset value lowercased (really shouldn't matter)
Trailing ; removed

How many mail clients have you tried this in?
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

Hi All,

I tried like this.

Code: Select all

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: [b]text/html[/b]; charset=iso-8859-1' . "\r\n";



if(mail($toid, $subject, $message, $from.$headers))
                {
                 echo "<div align=\"center\"><strong>Mail sent to the users in $filename successfully.....</strong></div>";
                }

In this $toid,$subject, $message and $from will come from textboxes.

Now my problem is if message contains any Links(href),then in mail that link is not coming.....

Please suggest me....

Am searching from last 3 days in Google......

Waiting for your valuable replies...

Thanks and regards
MADHU
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

Hi all....

Code: Select all

$headers  = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: [b]text/html[/b]; charset=iso-8859-1' . "\r\n"; 



if(mail($toid, $subject, $message, $from.$headers)) 
                { 
                 echo "<div align=\"center\"><strong>Mail sent to the users in $filename successfully.....</strong></div>"; 

              echo $message; //here also am getting the content with correct format(i.e with href)
                }

Please help me what is the problem....

Thanks and regards
MADHU
satheshf12000
Forum Commoner
Posts: 25
Joined: Mon Sep 04, 2006 5:38 pm

Post by satheshf12000 »

Try in this way:

Code: Select all

$eol = "\r\n";
$mailheader  = 'MIME-Version: 1.0' . $eol;
$mailheader .= 'Content-type: text/html; charset=iso-8859-1' . $eol;
$mailheader .= "From: XXX Mail Services<mailer@xxxxxx.com>". $eol;
$mailheader .= 'Return-Path: Madhu <no-reply@xxxxxx.com>'.$eol;    // this to set reply address.

mail($to,$subject,$msg,$mailheader);
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

hi satheshf12000,

you replaced "\r\n" with $eol .

i think what i implemented and your code both are same.
satheshf12000
Forum Commoner
Posts: 25
Joined: Mon Sep 04, 2006 5:38 pm

Post by satheshf12000 »

what are you sending in the $msg ??
madhu
Forum Commoner
Posts: 82
Joined: Fri Mar 03, 2006 9:34 am

Post by madhu »

$msg contains any content.

Example:

if i type http://mail.yahoo.com , then after sending mail am not able to get that as link(i.e href).

It is coming as a plain text in the mail Inbox.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You're going to need to show us more code. Namely, the bit that generates $msg.
Post Reply