Jump to content

Mail Function not Working


Rowno

Recommended Posts

Can anyone tell me why this script isn't sending any emails?

<?php
$message = "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<title>$subject</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
<style>
body
{
font-family:Arial;
} 
</style>
</head>
<body>
This email was sent by $name from the WEB SPIRITED Contact Us mail form and they sent this message:<br />
$message
<br />
Their reply email address is: $email
</body>
</html>
";
$message = wordwrap($message, "70");
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type:text/html;charset=iso-8859-1' . "\r\n";
$headers .= 'From: WEB SPIRITED <from email here>' . "\r\n";
$headers .= 'Reply-To: '.$email . "\r\n";

if ($subject == "I would like a website made")
{$toemail = "email 1";}
else
{$toemail = "email 2";}

if (mail($toemail, $subject, $message, $headers))
{
$success = "Your email has been sent.";
}
?>

Link to comment
Share on other sites

Hello, had a similar problem with HTML based email not to long ago myself..

 

After pleanty of agravasion and trial and error and help from here even.. I got all to work..

 

 

<?php
$to = $_POST['ref_trmail'];
$subject = '[Poetry Asylum] - ' . $ptitle;
$message = '
Your message here, including HTML markup..
';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Content-type: text/html; charset=us-ascii' . "\r\n";
$headers .= 'From: Poem Share <poetry@poetryasylum.com>' . "\r\n";
$headers .= 'To: ' . $_POST['ref_trname'] . ' <' . $_POST['ref_trmail'] . '>' . "\r\n";
$headers .= 'Reply-To: ' . $_POST['ref_yrname'] . ' <' . $_POST['ref_yrmail'] . '>' . "\r\n";
$headers .= '1\r\nX-MSMail-Priority: High' . "\r\n";
$headers .= 'X-Mailer: Poetry Asylum mailer v1.0' . "\r\n";
mail($to, $subject, $message, $headers);

 

now heres where I got thrown off and looks similar to you one...

your escapes of the double quotes in the message, take them out just leave the plain double quote like you would in any other html doc...

 

two pay attention to my version vs yours.. notice the single quotes vs the double quotes, and where they are placed..

 

thrid you may wanna change it up a smidge as I have left headers and what not that pertain to mine as im just copy an pasting it out of one of my files for examples sake..

 

fourth when you have changed what you need and added your stuff in the part that says your message here you should have a fully functional HTML sending php mailer..

 

Enjoy

Link to comment
Share on other sites

There is nothing wrong with the message, as I echoed out the variables to see if they were being set and the html message looked perfect and the my server does send mail because I have another mail script on my site that works perfectly but for some reason this script doesn't.

Link to comment
Share on other sites

Ok, here's my other mail script that works perfectly:

<?php
            $subject = "WEB SPIRITED Email Verification and Account Activation";

            $message = "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<title>WEB SPIRITED Email Verification and Account Activation</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
<style>
body
{
font-family:Arial;
} 
</style>
</head>
<body>
This email was send by WEB SPIRITED to verify that the email address you entered is correct and to activate your account.<br />
Please click on the link below to verify this email address and to activate your account.
<p>
<br />
<a href=\"link" title=\"Verify email and activate account\">link</a>
<p>
<br />
If this link isn't working, copy and paste the address into the address field of your internet browser.
</body>
</html>
";
            $message = wordwrap($message, "70");

            $headers = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type:text/html;charset=iso-8859-1' . "\r\n";
            $headers .= 'From: WEB SPIRITED <from email here>' . "\r\n";

            mail($email, $subject, $message, $headers);
?>

Can anyone see any reason why the script above shouldn't work compared to this one? Because they're both run on the same server and same site.

Link to comment
Share on other sites

try this fill in the correct info

<?php


$message = "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<title>$subject</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
<style>
body
{
font-family:Arial;
} 
</style>
</head>
<body>
This email was sent by $name from the WEB SPIRITED Contact Us mail form and they sent this message:<br />
$message
<br />
Their reply email address is: $email
</body>
</html>
";
$mess = wordwrap($message, "70");


$subject == "I would like a website made";

$name=" name off user";

$to="to the user email address";

$email=" from address email"

$to = $to;
$subject = $subject;
$message = $mess;
$headers = "From: $email\r\n" .
        'X-Mailer: PHP/' . phpversion() . "\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: text/html; charset=utf-8\r\n" .
        "Content-Transfer-Encoding: 8bit\r\n\r\n";



if ($subject == "I would like a website made"){

$toemail = "email 1";

}else{

$toemail = "email 2";
}

if (mail($to, $subject, $message, $headers)){

$success = "Your email has been sent.";
}
?>

Link to comment
Share on other sites

This is so frustrating, if I use the message from the working mail script it works but if I use the message from the not working mail script it doesn't work. So this means it's something in the message that's causing the problem, but what...  ???

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.