mail is not sending to my site to godaddy workspace - php

<?php
if($_REQUEST['submit']=='SEND'){
$to= 'info#mysatoristudio.com,aespino#brainwaveadvertising.com,sales#mpsinfoservices.com,tamali#mpsinfoservices.com,tathagata#mpsinfoservices.com,tamali#mysatoristudio.com';
/* $to='ananya#mpsinfoservices.com';*/
$mailmessage = '
<html>
<head>
<title>Contact Us</title>
</head>
<body>
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">
</td>
<tr>
<tr>
<td colspan="2">You have Successfully registerd for "Satori studio"</td>
</tr>
<tr>
<td colspan="2">Your Name : '.$_REQUEST['name'].'</td>
</tr>
<tr>
<td colspan="2">Your mail ID : '.$_REQUEST['email'].'</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</body>
</html>
';
$headers = "MIME-Version: 1.0"."\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
/* $headers .= "Content-type: text/html; charset=iso-8859-1"."\r\n";*/
$headers .= "From: Satori studio <info#mysatoristudio.com>" . "\r\n";
$subject = 'Registration for "Satori studio"';
mail($to,$subject,$mailmessage,$headers);
header("Location:index.php?msg=seccess");
}
?>
The mail is sending from my site to every mail server like google,yahoo etc...but not in godaddy workspace mail id...is this a coding problem???or others...Please suggest...

I got this to work by adding
ini_set('SMTP', "relay-hosting.secureserver.net");
ini_set('smtp_port', "25");
before calling the mail function, as follows :
public function sendEmail( $text , $subject , $name , $sender_email , $destination )
{
$headers="From:$name <$sender_email>\r\n";
$headers .= "Reply-To: $sender_email\r\n";
$headers .= "Date: " . date("r") . "\r\n";
$headers .= "Return-Path: $sender_email\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Message-ID: " . date("r") . $name ."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "Importance: High\r\n";
$headers .= "X-MXMail-Priority: High\r\n";
$headers .= "X-Mailer: PHP Mailer 1.0\r\n";
ini_set('SMTP', "relay-hosting.secureserver.net");
ini_set('smtp_port', "25");
mail( $destination , $subject , $text , $headers );
return true;
}
I also noticed that the mail only sends when using charset=iso-8859-1,
I think there might be something missing in the server configuration on godaddy workspace where it is not allowing utf-8 charset through mail. I think the support might help in this case if you really need the utf-8 charset.

Related

how to send image mailer using php mail function

i am trying to send html image mailer using php mail function on linux platform. There is one issue when i am trying to send simple html content then it successfully get delivered to its subscriber. but when i try to send emailer which contains few images then it fails to deliver it. below are two codes 1 by which simple html is delivered. 2 which is not getting delivered.
<?php
$to = "somebody#example.com, somebodyelse#example.com";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From: <webmaster#example.com>' . "\r\n";
$headers .= 'Cc: myboss#example.com' . "\r\n";
mail($to,$subject,$message,$headers);
?>
code 2:
<?php
//change this to your email.
$to = "abhinav#xyz.in";
$from = "abhinav.1#gmail.com";
$subject = "Hello! This is HTML email";
//begin of HTML message
$message= <<<EOF
<html>
<body bgcolor="#DCEEFC">
<center>
<b>Looool!!! I am reciving HTML email......</b> <br>
<font color="red">Thanks Mohammed!</font> <br>
* maaking.com
</center>
<br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine
</body>
</html>
EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
//options to send to cc+bcc
//$headers .= "Cc: [email]maa#p-i-s.cXom[/email]";
//$headers .= "Bcc: [email]email#maaking.cXom[/email]";
// now lets send the email.
mail($to, $subject, $message, $headers);
echo "Message has been sent....!";
?>
I corrected the code by which I am able to send image mailer below is the code:
<?php
$to= 'abhinav#xyz.com' . ',';
$to .= 'abhinav#gmail.com';
$sub='test1';
$msg= <<<EOF
<html>
<body>
<table>
<tr>
<td><img src="http://d32vlg867bsa1v.cloudfront.net/z/prod/w/2/i/zovi-logo2.png" />
</td>
</tr>
</table>
</body>
</html>
EOF;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: <centos_test#example.com>' . "\r\n";
mail($to,$sub,$msg,$headers);
?>
I am still working to sent highly customized mailer and will describe how it can once I found how it can be done.

How do I turn a PHP variable string to output HTML?

I am trying to create an autoresponder email and the content is a PHP variable. I want it to output HTML code and right now it's not.
//Example:
$respondmessage = " Hello $fullname,
We are confirming your Appointment today!
Please click here to confirm!
";
This outputs:
Hello Your Name,
We are confirming your Appointment today!
Please click here to confirm!
In the email. Is there a way to make the email accept HTML code?
You can following line as an header in your code :
$headers = "Content-type: text/html\r\n";
This will help you to create email into HTML
Assuming you're using the built in mail function in PHP:
<?php
// multiple recipients
$to = 'aidan#example.com' . ', '; // note the comma
$to .= 'wez#example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
This example is from: http://us2.php.net/manual/en/function.mail.php
The important part is the $headers variable.
By the way, as andrewsi mentioned - you need to escape your quotes:
$respondmessage = "Hello $fullname,
We are confirming your Appointment today!
Please click here to confirm!";
You have to include this header to your email script
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
From http://php.net/manual/en/function.mail.php example# 4
<?php
// multiple recipients
$to = 'aidan#example.com' . ', '; // note the comma
$to .= 'wez#example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>

PHP mail html format not working

Using php, and with this code I receive the email as a plain text, did I miss something? as I need to send formatted email which could contain links for example.
$to = "receiver#test.com";
$subject = "Password Recovery";
$body = '
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = "From: info#test.net\r\n"."X-Mailer: php";
if (mail($to, $subject, $body, $headers))
echo "Password recovery instructions been sent to your email<br>";
You've re-set your headers:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = "From: info#test.net\r\n"."X-Mailer: php";
You're missing a dot in that last line, which is over-writing the previous two:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: info#test.net\r\n"."X-Mailer: php";
Look at this example, this is sufficient to send mail in php:
<?php
//change this to your email.
$to = "abc#gmail.com";
$from = "Example#example.com";
$subject = "Hello! This is HTML email";
//begin of HTML message
$message ="
<html>
<body>
<p style=\"text-align:center;height:100px;background-color:#abc;border:1px solid #456;border-radius:3px;padding:10px;\">
<b>I am receiving HTML email</b>
<br/><br/><br/><a style=\"text-decoration:none;color:#246;\" href=\"www.example.com\">example</a>
</p>
<br/><br/>Now you Can send HTML Email
</body>
</html>";
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
//options to send to cc+bcc
//$headers .= "Cc: [email]maa#p-i-s.cXom[/email]";
//$headers .= "Bcc: [email]email#maaking.cXom[/email]";
// now lets send the email.
mail($to, $subject, $message, $headers);
echo "Message has been sent....!";
?>
I found the same problem with a specific mail server, in my case the solution was to set "\n" instead of "\r\n" as the end of line for the headers.
Even though your problem seems to be caused by re-assigning to $headers, I've ran into a similar problem and discovered the cause to be the double line-ending "/r/n". Some mail apps such as Bluemail, start the mail body (effectively ending the headers) after reading a double line ending.
In my case, it was solved by changing this:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: info#test.net\r\n"."X-Mailer: php";
to this:
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers = "From: info#test.net\n"."X-Mailer: php";

HTML formatted email does not display correctly

I'm still struggling with this mail script - I'm now getting all the marked up html through rather than seeing it as rendered html if that makes sense?
<?php
$mailheader .= "MIME-Version: 1.0\r\n";
$mailHeader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$formcontent .="<table border='1'>";
foreach ($_POST as $field=>$value)
{
$formcontent.="<tr>";
$formcontent .= "<td>$field:</td> <td>$value</td>";
$formcontent.="</tr>";
}
$formcontent .= '<tr><td>User-Agent: </td><td>'.$_SERVER['HTTP_USER_AGENT'].'</td>';
$formcontent .="</table>";
$recipient = "info#*******.com";
$subject = "Event feedback form";
$mailheader = "From: web.form#*******-events.co.uk\r\n";
$mailheader .= "Reply-To: $email\r\n";
$mailHeader .= "Content-type: text/html; charset=iso-8859-1\r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Failure!");
header("location:http://www.******-events.co.uk");
?>
Follow php's documentation:
You'll need html tags
<?php
// multiple recipients
$to = 'aidan#example.com' . ', '; // note the comma
$to .= 'wez#example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
I'd rather use a PHP class as PHPMailer for HTML emails. And btw I will add the full HTML document tags (html, head, body, etc...) for the mail body.
I'd missed these:
$formcontent = '<html><body>';
Thanks for everyone's time and input though
Jim

Why doesn't this php mail script work?

I made a php script that sends mail. It worked fine until i changed it so it sent stuff as html instead of just plain text. However, it isn't working. The script itself returns a success, but I'm not getting the email. I've checked my spam folder. Could anyone see why this isn't working? Thanks
<?php
$to = $_POST["mail"];
$subject = 'Registration at Campatet';
$message = '
<html>
<head>
<title>Registration at Campatet</title>
</head>
<body>
<p>Thank you for registering at Campatet!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: no-reply#campatet.com" . "\r\n";
if(mail($to, $subject, $message, $headers)){
echo "Success sending e-mail to: <b>".$to."</b>";
}
else{
echo "There was a error";
}
?>
Use this as your only header:
$headers = "Content-type: text/html; From: no-reply#campatet.com";
First, try removing the line
$headers = "MIME-Version: 1.0" . "\r\n";
Are you sure that the post variable is receiving it's address correctly? Try removing that and replacing it with the email address you are trying to use.
Have you ever been able to successfully send mail from your website at all?
Specifying email headers without a Reply-To header is often considered as reason to suspect spam. It doesn't matter that you don't want replies, just specify the Reply-To header.
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= 'From: no-reply#campatet.com' . "\r\n" . 'Reply-To: no-reply#campatet.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();

Categories