Hi all.,
I m having a website in which paypal acts as a payment gateway.,
i m using IPN to validate the payment and send confirmation mail to the recipients in my notiy url(e.g http://www.mysite.com/notify.php)
Everything works fine., but in yahoomail when i opened the email received and viewed the full headers of the mail.,
i can see the URL from which the mail is sent.
Like..
I am not sure about the other mail services.
I felt that this is not safety enough to protect my code..
I amusing the class file from the below link to send the email..
Also attached the file.
and here is my code which send the email using the script..
i have attached the email_message.p hp with this post..
since php file cannot be attached i save it as a .txt file.
Thanks.
vijay
I m having a website in which paypal acts as a payment gateway.,
i m using IPN to validate the payment and send confirmation mail to the recipients in my notiy url(e.g http://www.mysite.com/notify.php)
Everything works fine., but in yahoomail when i opened the email received and viewed the full headers of the mail.,
i can see the URL from which the mail is sent.
Like..
Code:
From Ticket Master Thu May 12 07:14:43 2011 X-Apparently-To: vays_ij@yahoo.co.in via..... ....... .............. Date: Mon, 09 May 2011 15:14:43 +0800 To: testing <vays_ij@yahoo.co.in> Subject: Ticket confirmation from ticketmaster X-PHP-Script: www.mysite.com/notify.php for 192.168.1.2(server IP) From: Ticket Master <booking@mysite.com> Reply-To: Ticket Master <booking@mysite.com> Sender: booking@mysite.com MIME-Version: 1.0 Content-Type: multipart/related; boundary="c052e8f7510af91ee938fb2081d381d1" Message-ID: <20110509151443.5890.booking@mysite.com> Content-Length: 96625
I felt that this is not safety enough to protect my code..
I amusing the class file from the below link to send the email..
Also attached the file.
Code:
http://www.phpclasses.org/package/9-PHP-PHP-mailer-to-compose-and-send-MIME-messages.html#download
Code:
<?php
require("email_message.php");
/*
* Trying to guess your e-mail address.
* It is better that you change this line to your address explicitly.
* $from_address="me@mydomain.com";
* $from_name="My Name";
*/
// $from_address=getenv("USER")."@".getenv("HOSTNAME").'<br>';
// $from_name=getenv("USERNAME");
$from_address="booking@mysite.com";
$from_name="Ticket Master";
$reply_name=$from_name;
$reply_address=$from_address;
$reply_address=$from_address;
$error_delivery_name=$from_name;
$error_delivery_address=$from_address;
/*
* Change these lines or else you will be mailing the class author.
*/
$to_name='Vijay anand';
$to_address='vays_ij@yahoo.co.in';
$subject="Ticket confirmation from ticketmaster";
$email_message=new email_message_class;
$email_message->SetEncodedEmailHeader("To",$guest_address,$guest_name);
$email_message->SetEncodedEmailHeader("From",$from_address,$from_name);
$email_message->SetEncodedEmailHeader("Reply-To",$reply_address,$reply_name);
$email_message->SetHeader("Sender",$from_address);
/*
* Set the Return-Path header to define the envelope sender address to which bounced messages are delivered.
* If you are using Windows, you need to use the smtp_message_class to set the return-path address.
*/
if(defined("PHP_OS")
&& strcmp(substr(PHP_OS,0,3),"WIN"))
$email_message->SetHeader("Return-Path",$error_delivery_address);
$email_message->SetEncodedHeader("Subject",$subject);
/*
* An HTML message that requires any dependent files to be sent,
* like image files, style sheet files, HTML frame files, etc..,
* needs to be composed as a multipart/related message part.
* Different parts need to be created before they can be added
* later to the message.
*
* Parts can be created from files that can be opened and read.
* The data content type needs to be specified. The can try to guess
* the content type automatically from the file name.
*/
$image=array(
"FileName"=>"http://www.mysite.com/logo.gif",
"Content-Type"=>"automatic/name",
"Disposition"=>"inline",
/*
* You can set the Cache option if you are going to send the same message
* to multiple users but this file part does not change.
*
"Cache"=>1
*/
);
$email_message->CreateFilePart($image,$image_part);
/*
* Parts that need to be referenced from other parts,
* like images that have to be hyperlinked from the HTML,
* are referenced with a special Content-ID string that
* the class creates when needed.
*/
$image_content_id=$email_message->GetPartContentID($image_part);
/*
* Many related file parts may be embedded in the message.
*/
$image=array(
"FileName"=>"http://www.mysite.com/images/voucher_header.jpg",
"Content-Type"=>"automatic/name",
"Disposition"=>"inline",
);
$email_message->CreateFilePart($image,$background_image_part);
$background_image_content_id="cid:".$email_message->GetPartContentID($background_image_part);
$html_message="<html>
<head>
<title>$subject</title>
<style type=\"text/css\"><!--
body{
margin:0px;
padding:0px;
}
--></style>
</head>
<body>";
$html_message.='<table background="'.$background_image_content_id.'" style="background-repeat:no-repeat;color: black ;font-family:Calibri;background-color: #FFFFFF;background-repeat:no-repeat;border:1px solid #000;" width="1000px" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding-left:10px;padding-bottom:20px;">
<tr>
<td align="left" valign="top"> </td>
<td align="left" valign="top"> </td>
<td height="140px" colspan="2" align="center" valign="bottom" style="font-size:40px;"><b>GUEST VOUCHER</b></td>
</tr>
<tr>
<td align="left" valign="top"> </td>
<td align="left" valign="top"> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td height="80px" colspan="4" align="left" valign="top"> </td>
</tr>
<tr>
<td height="40" align="left" valign="top">Package</td>
<td align="left" valign="top">GF456</td>
<td align="left" valign="top">Arrival</td>
<td align="left" valign="top">16-05-2011</td>
</tr>
<tr>
<td height="40" align="left" valign="top">RefNo</td>
<td align="left" valign="top">GKR459DK</td>
<td align="left" valign="top">Departure</td>
<td align="left" valign="top">18-05-2011</td>
</tr>
<tr>
<td height="40" align="left" valign="top">Customer Name</td>
<td align="left" valign="top">VIJAY ANAND</td>
<td align="left" valign="top">Check in</td>
<td align="left" valign="top">10:00hrs</td>
</tr>
<tr>
<td height="40" align="left" valign="top">Member</td>
<td align="left" valign="top">GUEST</td>
<td align="left" valign="top">No of Nights</td>
<td align="left" valign="top">2</td>
</tr>
<tr>
<td height="40" align="left" valign="top">COUNTRY</td>
<td align="left" valign="top">INDIA</td>
<td align="left" valign="top">Booked date</td>
<td align="left" valign="top">15-05-2011</td>
</tr>
<tr>
<td height="40" align="left" valign="top">Hotel Name</td>
<td align="left" valign="top">HOTEL NAME</td>
<td align="left" valign="top"> </td>
<td align="left" valign="top"> </td>
</tr>
<tr>
<td height="40" align="left" valign="top">Hotel Address</td>
<td colspan="3" align="left" valign="top">STREET NAME, CITY</td>
</tr>
<tr>
<td height="40" colspan="4" align="left" valign="top"><hr></td>
</tr>
<tr>
<td colspan="4" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" align="left" valign="top">Room No</td>
<td align="left" valign="top">Room Type</td>
<td align="left" valign="top">Extra beds</td>
<td align="left" valign="top">Breakfast</td>
</tr>
<tr>
<td align="left" valign="top">1</td>
<td align="left" valign="top">SINGLE</td>
<td align="left" valign="top">NO</td>
<td align="left" valign="top">YES</td>
</tr></table></td>
</tr>
<tr>
<td height="40" colspan="4" align="left" valign="top"><hr></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top">Remarks</td>
<td colspan="2" align="left" valign="top">Customer Support Center 24/7</td>
</tr>
<tr>
<td colspan="2" align="left" valign="top">All special request are subject to availability upon arrival</td>
<td colspan="2" align="left" valign="top">http://www.mysite.com/customersupport.html</td>
</tr>
<tr>
<td colspan="4" align="left" valign="top"> </td>
</tr>
<tr>
<td colspan="4" align="left" valign="top">NOTES</td>
</tr>
<tr>
<td colspan="4" align="left" valign="top">- IMPORTANT :
- The total price for this booking does not include mini-bar items, telephone usage, laundry service, etc. If applicable, the hotel will bill you directly. <br>
- In cases where Breakfast is included with the room rate, please note that hotels may charge extra for children travelling with their parents. <br>
Additional guest requesting extra beds are required to pay for breakfast. If appicable, the hotel will bill you directly. </td>
</tr>
<tr>
<td height="70" colspan="4" align="left" valign="top"><img src=\'cid:'.$image_content_id.'\'></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>';
$email_message->CreateQuotedPrintableHTMLPart($html_message,"",$html_part);
/*
* It is strongly recommended that when you send HTML messages,
* also provide an alternative text version of HTML page,
* even if it is just to say that the message is in HTML,
* because more and more people tend to delete HTML only
* messages assuming that HTML messages are spam.
*/
$text_message="This is an HTML message. Please use an HTML capable mail program to read this message.";
$email_message->CreateQuotedPrintableTextPart($email_message->WrapText($text_message),"",$text_part);
/*
* Multiple alternative parts are gathered in multipart/alternative parts.
* It is important that the fanciest part, in this case the HTML part,
* is specified as the last part because that is the way that HTML capable
* mail programs will show that part and not the text version part.
*/
$alternative_parts=array(
$text_part,
$html_part
);
$email_message->CreateAlternativeMultipart($alternative_parts,$alternative_part);
/*
* All related parts are gathered in a single multipart/related part.
*/
$related_parts=array(
$alternative_part,
$image_part,
$background_image_part
);
$email_message->AddRelatedMultipart($related_parts);
/*
* The message is now ready to be assembled and sent.
* Notice that most of the functions used before this point may fail due to
* programming errors in your script. You may safely ignore any errors until
* the message is sent to not bloat your scripts with too much error checking.
*/
$error=$email_message->Send();
/*
if(strcmp($error,""))
echo "Error: $error\n";
else
echo "Message sent to $to_name\n";
*/
?>
since php file cannot be attached i save it as a .txt file.
Thanks.
vijay
Comment