Jump to content

php mail function question


jmcall10

Recommended Posts

I have this code

[code]
$to = "[email protected]";
$subject = "Test email";
            
$message = "$mailMessage";
            
$headers = "From: [email protected]";
$headers .= "\nReply-To: [email protected]";
            
$sentOk = mail($to,$subject,$message,$headers);

[/code]

I have $mailMessage as a text area input.

The email sends ok but what I want it to do is for me to be able to put html code in the text area.

i.e if I put [code]<a href="http://www.phpfreaks.com">phpfreaks</a>[/code]

I want it to be read like [a href=\"http://www.phpfreaks.com\" target=\"_blank\"]phpfreaks[/a]

any ideas

Thanks in advance

jmcall10
Link to comment
https://forums.phpfreaks.com/topic/11889-php-mail-function-question/
Share on other sites

Thanks for that however I have a strange problem

When I use

[code]
<a href="http://www.phpfreaks.com>phpfreaks</a>
[/code]

The link is clickable in outlook

but when I view the email in hotmail the link is the colour of a link but is not clickable?

I have checked hotmail settings and cant find anything

also when I check lycos mail it is not even the colour of a link?

Any ideas

thanks in advance

jmcall10
Here is the new code I have.

Can someone tell me whats wrong

[code]
$to = "[email protected]";
$subject = "$mailSubject";

$message = "$mailMessage";

$headers = "From: [email protected]";
$headers .= "\nReply-To: [email protected]";
$headers .= "\nMIME-Version: 1.0";
$headers .= "\nContent-type: text/html; charset=iso-8859-1";

$sentOk = mail($to,$subject,$message,$headers);
[/code]


Thanks in advance

jmcall10
There are a lot of factors when it comes to filtering email.

It depends if the email in the Junk folder or the inbox. If the sender in a black list, or not, the IP address of the sender, the headers, the format of the message.
In your message, try to add
[code]
<html>
<head>
<title>Message</title>
</head>
<body>

YOUR Message

</body>
</html>
[/code]

Even though everything above the body tag get stripped, this should lower the spam filter points.
ok still no such luck.

I will post all the code within the function I use and maybe it will make more sense

If someone could try it out I wud be much appreciated

I have a database with a table called 'mail_members2'

in the table are 3 fields:

'mail_id', 'mail_name' and 'mail_address'

The code takes in the subject and the text and mails it out to all in table.
Only thing that doesnt work for me is when I use html link code.

[code]
function newsletter(){
global $config, $subject,$mailSubject, $message, $mailMessage;
    if (is_loggedin()) {
        if ($_SERVER['REQUEST_METHOD'] == "POST") {
            if ($mailSubject == "" || $mailMessage == "") {
        echo "
            <html>
            <body>";
            
                        
        echo"
        We are sorry but the subject or message field was empty!
        </body>
        </html>";
        
} else {
    mysql_connect($config['sql_host'], $config['sql_username'], $config['sql_password']);
        mysql_select_db($config['sql_database']);
            
            $query = mysql_query("SELECT * FROM `mail_members2`");
            $num_rows = mysql_num_rows($query);
                
    
        while ($row = mysql_fetch_array($query)) {
            
            $to = "$row[mail_address]";
            $subject = "$mailSubject";
            
            $message = "Hey " . $row[mail_name]."<br>";
            $message .= "$mailMessage";
            
            $headers = "From: [email protected]";
            $headers .= "\nReply-To: [email protected]";
            $headers .= "\nMIME-Version: 1.0";
            $headers .= "\nContent-type: text/html; charset=iso-8859-1";
            
            $sentOk = mail($to,$subject,$message,$headers);
            }
        
        
        echo "
            <html>
            <body>";
            
            echo"
                NewsLetter has been sent!         
            </body>
            </html>";
    }
        
        
        
} else {
        echo "
            <html>
            <body>";
                        
            
        echo"
        <form method=\"post\" action=\"?act=newsletter\">
            <table>
                <tr>
            <td >Subject:</td>
            <td ><input type=\"text\" name=\"mailSubject\" size=\"20\"></td>
                </tr>
                <tr>
            <td >Message:</td>
            <td ><textarea rows=\"19\" name=\"mailMessage\" cols=\"60\"></textarea></td>
                </tr>
            
            </table>
            <input type=\"submit\" value=\"Send NewsLetter\" >
            </body>
            </html>";
    }
} else {
        echo "
            <html>
            <body>
            You are not logged in.

            </body>
            </html>";
    }

}

[/code]

The code is part of a larger set of code that requires a log in. Simply strip the code accordingly

I would really appreciate help on this matter

Thanks in advance

jmcall10

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.