Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2005, 05:15 PM
Authorized User
 
Join Date: Dec 2003
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Send two emails instead of one

I can't figure out why this script sends two copies instead of one. Is there a problem with the script? Is there something wrong with my server? Thanks!

<?php

$email = "x@x.edu";
$from = "x@x.org";
$subject = "subject";
$message = "message";

function mail_attach($to, $from, $subject, $message) {

   $header = "From: ".$from."\r\n";
   $header.= "To: ".$to."\r\n";
   $header.= "MIME-Version: 1.0\r\n";
   $header.= "Content-Type: multipart/mixed;\r\n";
   $header.= " boundary=\"".$mime_boundary."\"\r\n";
   $header.= "Return-Path:<x@x.org>\r\n";

   $content.= $message."\r\n";

   mail($to, $subject, $content, $header);
   }

mail_attach( $email, "x@x.org", "$subject", "$message");

?>

 
Old January 27th, 2005, 05:46 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Is this function is called after submitting the form?

Om Prakash
 
Old January 28th, 2005, 11:00 AM
Authorized User
 
Join Date: Dec 2003
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was calling it by submitting a form, but because of the double mailing I have pared it down and tried by just saving the script above as a PHP file, uploading it my server and then loading the page with the script. It still sent two emails instead of one.

 
Old January 28th, 2005, 11:54 AM
Authorized User
 
Join Date: Dec 2003
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

figured it out. I have to remove the line
 $header.= "To: ".$to."\r\n";
its redundent!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to send emails maitias C# 2005 2 February 1st, 2006 01:09 PM
send emails to several users femig VBScript 4 April 15th, 2005 07:42 AM
Send Emails in ASP tdaustin Classic ASP Basics 4 August 12th, 2004 07:09 PM
Send Emails and Attachments. mistry_bhavin General .NET 2 August 11th, 2004 10:05 AM
Using Mapi to send emails in VBA - Help? Magic_Hat Excel VBA 1 May 4th, 2004 07:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.