Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problem with PHP mailing again!!!
Old 08-05-2004, 01:40 PM Problem with PHP mailing again!!!
Junior Talker

Posts: 2
Trades: 0
Hello everybody,

I tried to improve the code and the comments!!
Here is my problem : I tried to send the mail from a form via this script. I received normally the mail across "the switch operation" (see the code) but I unfortunately didn't received this mail in copy (the Cc-Bcc) does not work!
Someone could help me, something's wrong in the code?
Thanx a lot.



<?php


// get required base data
$contactTime = date('d.m.Y H:i:s',time());
$contactLang = strtoupper($_POST['lng']);
$contactClub = $_POST['club'];
$contactTitle = $_POST['title'];
$contactLastName = stripslashes($_POST['lastname']);
$contactFirstName = stripslashes($_POST['firstname']);
$contactAddress = stripslashes($_POST['address']);
$contactCity = stripslashes($_POST['city']);
$contactEmail = stripslashes($_POST['email']);
$contactDayPhone = stripslashes($_POST['dayphone']);
$contactNightPhone = stripslashes($_POST['nightphone']);

//choice of checkbox
switch($contactClub)
{
case 'geneva' : $mailTo = 'geneva@anywhere.ch';
$clubName = 'Genève';
break;
case 'lausanne' : $mailTo = 'lausanne@anywhere.ch';
$clubName = 'Lausanne';
break;
case 'mystery' : $mailTo = 'mystery@anywhere.ch';
$clubName = 'Lausanne';
break;
case 'zurich' : $mailTo = 'zuerich@anywhere.ch';
$clubName = 'Zürich';
break;
case 'blues' : $mailTo = 'blues@anywhere.fr';
$clubName = 'Blues';
break;
}
//redirection when mail is gone
$redirect = 'thanks.html';
//building the mail
$mailToName = 'Anywhere';
$mailSubject = 'your chance';
$mailBody = "
<b>Anywhere 06/04</b>
<br><br>
<table cellpadding='0' cellspacing='0' border='0'>
<tr>
<td width='200'>Langue</td>
<td width='30'>&nbsp;:&nbsp;</td>
<td>$contactLang</td>
</tr>
<tr>
<td width='200'>Date/heure d'envoi</td>
<td width='30'>&nbsp;:&nbsp;</td>
<td>$contactTime</td>
</tr>
<tr>
<td colspan='3'>&nbsp;</td>
</tr>
<tr>
<td>Club</td>
<td>&nbsp;:&nbsp;</td>
<td>$clubName</td>
</tr>
<tr>
<td colspan='3'>&nbsp;</td>
</tr>
<tr>
<td>Last name</td>
<td>&nbsp;:&nbsp;</td>
<td>$contactTitle</td>
</tr>
<tr>
<td>Last name</td>
<td>&nbsp;:&nbsp;</td>
<td>$contactLastName</td>
</tr>
<tr>
<td>First name</td>
<td>&nbsp;:&nbsp;</td>
<td>$contactFirstName</td>
</tr>
<tr>
<td>Address</td>
<td>&nbsp;:&nbsp;</td>
<td>$contactAddress</td>
</tr>
<tr>
<td>Zipcode / City</td>
<td>&nbsp;:&nbsp;</td>
<td>$contactCity</td>
</tr>
<tr>
<td>E-Mail</td>
<td>&nbsp;:&nbsp;</td>
<td><a href='mailto:$contactEmail'>$contactEmail</a></td>
</tr>
<tr>
<td>Day phone</td>
<td>&nbsp;:&nbsp;</td>
<td>$contactDayPhone</td>
</tr>
<tr>
<td>Night phone</td>
<td>&nbsp;:&nbsp;</td>
<td>$contactNightPhone</td>
</tr>
</table>
"; // end mailBody


/*
* don't touch anything from here to the end of file !
*/



// finalize mail
$htmlContent = "<html>
<head>
<title>$mailSubject</title>
</head>

<body>
$mailBody
</body>
</html>"; // end finalization

// mail headers
$headers = array(
"Subject" => "$mailSubject",
"Date" => date("D, d M Y H:i:s O"),
"From" => "$contactFirstName $contactLastName <$contactEmail>",
"To" => "$mailToName <$mailTo>",
"Content-Type" => "text/html; charset=iso-8859-1"
);

// mail socket-openclose connection
$debug = false;
$connect = fsockopen("smtp.anywhere.ch", 25, $errno, $errstr, 30) or die("Could not talk to the sendmail server!");
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");
fputs($connect, "EHLO blues.anywhere.ch\r\n");
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");
fputs($connect, "MAIL FROM:<NOREPLY@anywhere.com>\r\n");
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");
fputs($connect, "RCPT TO:<$mailTo>\r\n");
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");
fputs($connect, "RCPT BCC:<mario@anywhere.com>\r\n");
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");
fputs($connect, "DATA\r\n");
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");
$socketheaders = "";
foreach($headers as $key=>$value )
$socketheaders .= $key.": $value\r\n";
fputs($connect, $socketheaders);
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");
fputs($connect, "\r\n".str_replace("\n","",str_replace("\r\n","",$ htmlContent))."\r\n");
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");
fputs($connect, "\r\n\r\n.\r\n");
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");
fputs($connect, "RSET\r\n");
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");
fputs($connect, "QUIT\r\n");
$rcv = fgets($connect, 1024);
if($debug) print("<br>[$rcv]");

// redirect
header("Location: $redirect");


// end form.php

?>
santille is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-05-2004, 07:52 PM
troatie's Avatar
Skilled Talker

Posts: 64
Trades: 0
I didn't dig into your code too much, but is there a reason you're not using the mail() command?

http://us4.php.net/manual/en/function.mail.php
__________________

Please login or register to view this content. Registration is FREE
troatie is offline
Reply With Quote
View Public Profile Visit troatie's homepage!
 
Old 08-08-2004, 06:09 AM
Super Talker

Posts: 121
Trades: 0
how do u send html emails to multiple email recipitants quickly?
vegancoder is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problem with PHP mailing again!!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14507 seconds with 12 queries