Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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");

?>

Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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.

Reply With Quote
  #4 (permalink)  
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!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:22 PM.


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