Try this:

  require_once('Mail.php');
  require_once('Mail/mime.php');

  function sendIcalEmail ($firstname,$lastname,$email,$meeting_date,$meeting_name,$meeting_duration) { 

// Data about the sender & email
$from_name = "My Name"; 
$from_address = "myname@mydomain.com"; 
$subject = "Meeting Booking"; //Doubles as email subject and meeting subject in calendar 
$meeting_description = "Here is a brief description of my meeting\n\n"; 
$meeting_location = "My Office"; //Where will your meeting take place 

// SMTP details
$smtp_params = array (
  "host" => "smtp.myserver.com",
  "port" => 25,
  "auth" => TRUE,
  "username" => "user@myserver.com",
  "password" => "pass"
);

//Convert MYSQL datetime and construct iCal start, end and issue dates 
$meetingstamp = strtotime($meeting_date . " UTC");     
$dtstart= gmdate("Ymd\THis\Z",$meetingstamp); 
$dtend= gmdate("Ymd\THis\Z",$meetingstamp+$meeting_duration); 
$todaystamp = gmdate("Ymd\THis\Z"); 

//Create unique identifier 
$cal_uid = date('Ymd').'T'.date('His')."-".rand()."@mydomain.com"; 

// Build sender/recipient in the form PEAR::Mail wants them
$sender = "$from_name <$from_address>";
$recipient = "$firstname $lastname <$email>";

//Create Email Headers 
$headers = array (
  'From' => $sender, 
  'Reply-To' => $sender, 
  'Return-Path' => $sender,
  'Subject' => $subject 
);

//Create Email Body (HTML) 
$bodyhtml = "<html>\r\n<body>\r\n<p>Dear $firstname $lastname,</p>\r\n<p>Here is my HTML Email / Used for Meeting Description</p>\r\n</body>\r\n</html>"; 

//Create ICAL Content (Google rfc 2445 for details and examples of usage) 
$ical = "BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
ORGANIZER:MAILTO:$from_address
DTSTART:$dtstart
DTEND:$dtend
LOCATION:$meeting_location
TRANSP:OPAQUE
SEQUENCE:0
UID:$cal_uid
DTSTAMP:$todaystamp
DESCRIPTION:$meeting_description
SUMMARY:$subject
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR";    

// Create the Mime message object
$mime = new Mail_mime("\r\n");

// Add the HTML to the object
$mime->setHTMLBody($bodyhtml);

// Add the attachment
$file_name = "dispatch.ics";
$content_type = "text/calendar";
$mime->addAttachment ($ical, $content_type, $file_name, 0);

// Get the MIME message
$body = $mime->get();
$headers = $mime->headers($headers);

// Create an SMTP object
$mail =& Mail::factory("smtp", $smtp_params); 

// Send the message
return ($mail->send($recipient, $headers, $body) === 1) ? TRUE : FALSE;

  }
  • You will need ALL THREE of Mail, Mail_mime and Net_SMTP installed (you can do this with the command 'pear install <extension name>')

  • You will need to configure the details of your SMTP server at the top of the function

  • The attachment is no longer written to disk, so you don't need to worry about deleting it

Not actually tested it so let me know how you get on...

    Hmm,

    I get the following error:

    Fatal error: Class 'Mail_mime' not found in /home/rcranney/public_html/testdomains/flex/mail_old3.php on line 132

    I've checked with my host and they assured me that the Mail_mime is included and sent me the log when they tried to re-install it:

    asojeff@caesar [~]# pear install Mail_mime
    pear/Mail_mime is already installed and is the same as the released version 1.8.1
    install failed

        require_once('Mail.php'); 
        require_once('Mail/mime.php');

      If you don't get any errors when you execute those, the classes should be available, but you have to include()/require() them in your script, in the global scope (preferably at the start of the script, not inside a function...)

        DaveRandom;10973030 wrote:
          require_once('Mail.php'); 
          require_once('Mail/mime.php');

        If you don't get any errors when you execute those, the classes should be available, but you have to include()/require() them in your script, in the global scope (preferably at the start of the script, not inside a function...)

        Right, I get no errors on those, just on line 132 which is the...

        $mime = new Mail_mime("\r\n");

          If they fail, ask the Host for the absolute canonical path of the PEAR install directory, and include them using that path.

          Check the PEAR install dir is in the include path with get_include_path()

            DaveRandom;10973032 wrote:

            If they fail, ask the Host for the absolute canonical path of the PEAR install directory, and include them using that path

            Moving the require_once() into the Function stopped that error coming, but then I get an error sending the email. No error description, just "A problem occurred sending email" which is the return text above as the result = FALSE on email sending.

            Think I should give up!

              Change the last line of the function to

              echo $mail->send($recipient, $headers, $body);

              ...and see what you get

                Ok,

                I get this error....

                Failed to set sender: My Name [SMTP: Invalid response code received from server (code: 501, response: >: "@" or "." expected after "My")]A problem occured sending email

                Which I think is because I am using localhost as the host, which I would have thought was ok?

                When I change to mail.richardcranney.com (my actual web address) I keep getting a time out error.

                DaveRandom;10973035 wrote:

                Change the last line of the function to

                echo $mail->send($recipient, $headers, $body);

                ...and see what you get

                  Try changing

                      // Build sender/recipient in the form PEAR::Mail wants them 
                      $sender = "$from_name <$from_address>"; 
                      $recipient = "$firstname $lastname <$email>";

                  ...to...

                      // Build sender/recipient in the form PEAR::Mail wants them 
                      $sender = "<$from_address>"; 
                      $recipient = "<$email>";

                  Doesn't seem to like specifying the name in the SMTP 'MAIL FROM:' command, i'm guessing you might have the same problem with the 'RCPT TO:' command. Hopefully that will sort it out.

                    Using this PEAR method I can't get it to actually send an email. When I did the echo, it was due to a timeout when using mail.richardcranney.com or another error when using localhost.

                    The part you mentioned was for the AntiAbuse things right? Sorry, just been having 2 conversations in 1 at the minute 🙂

                    DaveRandom;10973038 wrote:

                    Try changing

                        // Build sender/recipient in the form PEAR::Mail wants them 
                        $sender = "$from_name <$from_address>"; 
                        $recipient = "$firstname $lastname <$email>";

                    ...to...

                        // Build sender/recipient in the form PEAR::Mail wants them 
                        $sender = "<$from_address>"; 
                        $recipient = "<$email>";

                    Doesn't seem to like specifying the name in the SMTP 'MAIL FROM:' command, i'm guessing you might have the same problem with the 'RCPT TO:' command. Hopefully that will sort it out.

                      We are now starting to get to a point where I can't really tell you what is wrong without seeing the full code/having access to your hosting server - obviously you can't post those here, and shouldn't give them to anyone anyway.

                      The problems you are having when connecting to localhost are related to the SMTP protocol itself, which can be a tricky beast - I have spent much of my working life shouting at SMTP servers which aren't doing what I expect them to.

                      Why you can't connect to mail.richardcranney.com I don't know (I can telnet to it on port 25 and get a valid SMTP on the other end) - if the connection is timing out I would guess the DNS is not resolving right from your server, or there is an IP routing problem.

                      Should 'localhost' and 'mail.richardcranney.com' resolve to the same machine from your hosting server? In other words, is your hosting server the same box as your mail server?

                        DaveRandom;10973043 wrote:

                        We are now starting to get to a point where I can't really tell you what is wrong without seeing the full code/having access to your hosting server - obviously you can't post those here, and shouldn't give them to anyone anyway.

                        The problems you are having when connecting to localhost are related to the SMTP protocol itself, which can be a tricky beast - I have spent much of my working life shouting at SMTP servers which aren't doing what I expect them to.

                        Why you can't connect to mail.richardcranney.com I don't know (I can telnet to it on port 25 and get a valid SMTP on the other end) - if the connection is timing out I would guess the DNS is not resolving right from your server, or there is an IP routing problem.

                        Should 'localhost' and 'mail.richardcranney.com' resolve to the same machine from your hosting server? In other words, is your hosting server the same box as your mail server?

                        I can email you the full script if you like. My site is hosted with asmallorange.com and they have advised me to use localhost as the mail server.

                        When I use it on the following, it works:

                        	//$firstname is the first name of target
                        	//$lastname is the last name of target
                        	//$email is the targets email address
                        	//$meeting_date is straight from a DATETIME mysql field and assumes UTC.
                        	//$meeting_name is the name of your meeting
                        	//$meeting_duretion is the duration of your meeting in seconds (3600 = 1 hour)
                        	$firstname = "John";
                        	$lastname = "Smith";
                        	$email = "richcranney@googlemail.com";
                        	$meeting_date = "2011-02-25 13:40:00"; //mysql format
                        	$meeting_name = "Hello";
                        	$meeting_duration = 3600;
                        
                        //returns true or false
                        $result = sendIcalEmail($firstname,$lastname,$email,$meeting_date,$meeting_name,$meeting_duration);
                        
                        //display result
                        if($result) {
                        	echo "Email sent successfully.";
                        } else {
                        	echo "A problem occured sending email";
                        }
                        
                        
                          function sendIcalEmail ($firstname,$lastname,$email,$meeting_date,$meeting_name,$meeting_duration) {
                            $from_name = "Richard Cranney"; 
                            $from_address = "test@richardcranney.com"; 
                            $subject = "Meeting Booking"; //Doubles as email subject and meeting subject in calendar 
                            $meeting_description = "Here is a brief description of my meeting\n\n"; 
                            $meeting_location = "My Office"; //Where will your meeting take place 
                        
                        //Convert MYSQL datetime and construct iCal start, end and issue dates 
                        $meetingstamp = strtotime($meeting_date . " UTC");      
                        $dtstart= gmdate("Ymd\THis\Z",$meetingstamp); 
                        $dtend= gmdate("Ymd\THis\Z",$meetingstamp+$meeting_duration); 
                        $todaystamp = gmdate("Ymd\THis\Z"); 
                        
                        //Create unique identifier 
                        $cal_uid = date('Ymd').'T'.date('His')."-".rand()."@mydomain.com"; 
                        
                        //Create Email Headers 
                        $headers = array ( 
                          "From" => "$from_address", 
                          "Reply-To" => "$from_address",
                          "Subject" => "$subject",
                          "Return-Path" => "$sender",
                          "MIME-Version" => "1.0" 
                        ); 
                        
                        //Create Email Body (HTML) 
                        $body = "<html>\r\n<body>\r\n<p>Dear $firstname $lastname,</p>\r\n<p>Here is my HTML Email / Used for Meeting Description</p>\r\n</body>\r\n</html>";
                        
                        //Create ICAL Content (Google rfc 2445 for details and examples of usage) 
                        $ical = "BEGIN:VCALENDAR
                        PRODID:-//Google Inc//Google Calendar 70.9054//EN
                        VERSION:2.0
                        CALSCALE:GREGORIAN
                        METHOD:PUBLISH
                        BEGIN:VEVENT
                        DTSTART:20110110T110000Z
                        DTEND:20110110T120000Z
                        DTSTAMP:20110109T010919Z
                        UID:sjt64vqadlhlb1j8edi18oeelo@google.com
                        CREATED:20110110T093149Z
                        DESCRIPTION:
                        LAST-MODIFIED:20110110T093149Z
                        LOCATION:
                        SEQUENCE:0
                        STATUS:CONFIRMED
                        SUMMARY:Yes it works
                        TRANSP:OPAQUE
                        END:VEVENT
                        END:VCALENDAR
                        ";
                        
                        // Define data about the attachment 
                        $fileatt = 'dispatch.ics'; // Path to the file 
                        $fileatt_type = "text/calendar"; // File Type 
                        $attachments = array($fileatt => $fileatt_type); 
                        
                        // write ICAL to file 
                        file_put_contents($fileatt,$ical); 
                        
                        //SEND MAIL 
                        $mailresult = mail_attachments( $email, $subject, $body, $attachments, $headers ); 
                        
                        // Delete local file 
                        unlink($fileatt); 
                        
                        // Return result of sending email 
                        return $mailresult;
                          } 
                        
                        
                          function mail_attachments ($to, $subject, $body, $attachments, $headers = FALSE, $mailparams = FALSE) { 
                            // Get random hash and define first boundary string 
                            $mixedboundary = 'boundary-mixed-'.($random_hash = md5(time())); 
                            // Validate $headers, unset the content-type if it is set and overwrite it with multipart/mixed 
                            if (!$headers) $headers = array(); else foreach ($headers as $header => $data) if (strtolower($header) == 'content-type') unset($headers[$header]); 
                            $headers['Content-Type'] = "multipart/mixed; boundary=\"$mixedboundary\""; 
                            // Build extra headers into a string 
                            $headersarr = array(); 
                            foreach ($headers as $header => $data) $headersarr[] = "$header: $data"; 
                            $headerstr = implode("\r\n",$headersarr); 
                            // Start building body 
                            $bodystr = "--$mixedboundary\r\n"; 
                            if (is_array($body)) { 
                              if (isset($body['html']) && isset($body['text'])) { 
                                // Both text and html have been passed, build extra multipart/alternative section 
                                $bodystr .= "Content-Type: multipart/alternative; boundary=\"".($altboundary = "boundary-alt-$random_hash")."\"\r\n\r\n--$altboundary\r\nContent-Type: text/plain; charset=\"iso-8859-1\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n".$body['text']."\r\n\r\n--$altboundary\r\nContent-Type: text/plain; charset=\"iso-8859-1\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n".$body['html']."\r\n\r\n--$altboundary--\r\n\r\n--$mixedboundary"; 
                              } else if (($html = isset($body['html'])) || isset($body['text'])) { 
                                // Only one of text or html have been passed, build as appropriate 
                                $bodystr .= "Content-Type: text/".(($html) ? 'html' : 'plain')."; charset=\"iso-8859-1\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n".(($html) ? $body['html'] : $body['text'])."\r\n\r\n--$mixedboundary"; 
                              } else return FALSE; 
                            } else if (is_string($body)) { 
                              // $body is a string, assume HTML 
                              $bodystr .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\nContent-Transfer-Encoding: 7bit\r\n\r\n$body\r\n\r\n--$mixedboundary"; 
                            } else return FALSE; 
                            // Loop through attachments, base64 encode them and add them to $bodystr 
                            foreach ($attachments as $attachment => $type) if (is_file($attachment)) $bodystr .= "\r\nContent-Type: $type; name=\"".basename($attachment)."\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment\r\n\r\n".chunk_split(base64_encode(file_get_contents($attachment)))."\r\n--$mixedboundary"; 
                            $bodystr .= "--"; 
                        
                        
                        // Execute mail() and return the result 
                        //return ($mailparams) ? @mail($to,$subject,$bodystr,$headerstr,$mailparams) : @mail($to,$subject,$bodystr,$headerstr); 
                        // Now try with PEAR
                        require_once "Mail.php";
                        $host = "localhost";
                        $username = "test@richardcranney.com";
                        $password = "******";
                        
                        $smtp = Mail::factory('smtp',
                        array ('host' => $host,
                        'auth' => true,
                        'username' => $username,
                        'password' => $password));
                        
                        return ($mailparams) ? $smtp->send($to, $headers, $bodystr, $mailparams) : $smtp->send($to, $headers, $bodystr);
                        
                        if (PEAR::isError($mail)) {
                        	echo("<p>" . $mail->getMessage() . "</p>");
                        } else {
                        	echo("<p>Message successfully sent!</p>");
                        }
                        
                          }
                        
                        

                        Post continues on next page....

                          When I try it in this latest version, it doesn't work as the PEAR class needs the host to have the @ or . in it.

                          	//$firstname is the first name of target
                          	//$lastname is the last name of target
                          	//$email is the targets email address
                          	//$meeting_date is straight from a DATETIME mysql field and assumes UTC.
                          	//$meeting_name is the name of your meeting
                          	//$meeting_duretion is the duration of your meeting in seconds (3600 = 1 hour)
                          	$firstname = "John";
                          	$lastname = "Smith";
                          	$email = "richcranney@googlemail.com";
                          	$meeting_date = "2011-02-25 13:40:00"; //mysql format
                          	$meeting_name = "Hello";
                          	$meeting_duration = 3600;
                          
                          //returns true or false
                          $result = sendIcalEmail($firstname,$lastname,$email,$meeting_date,$meeting_name,$meeting_duration);
                          
                          //display result
                          if($result) {
                          	echo "Email sent successfully.";
                          } else {
                          	echo "A problem occured sending email";
                          }
                          
                          
                           function sendIcalEmail ($firstname,$lastname,$email,$meeting_date,$meeting_name,$meeting_duration) {
                          require_once('Mail.php');
                          require_once('Mail/mime.php');
                             // Data about the sender & email
                             $from_name = "My Name";
                             $from_address = "test@richardcranney.com";
                             $subject = "Meeting Booking"; //Doubles as email subject and meeting subject in calendar
                             $meeting_description = "Here is a brief description of my meeting\n\n";
                             $meeting_location = "My Office"; //Where will your meeting take place
                          
                             // SMTP details
                             $smtp_params = array (
                               "host" => "localhost",
                               "port" => 25,
                               "auth" => TRUE,
                               "username" => "test@richardcranney.com",
                               "password" => "****"
                             );
                          
                             //Convert MYSQL datetime and construct iCal start, end and issue dates
                             $meetingstamp = strtotime($meeting_date . " UTC");
                             $dtstart= gmdate("Ymd\THis\Z",$meetingstamp);
                             $dtend= gmdate("Ymd\THis\Z",$meetingstamp+$meeting_duration);
                             $todaystamp = gmdate("Ymd\THis\Z");
                          
                             //Create unique identifier
                             $cal_uid = date('Ymd').'T'.date('His')."-".rand()."@mydomain.com";
                          
                             // Build sender/recipient in the form PEAR::Mail wants them
                             $sender = "$from_address";
                             $recipient = "$$email";
                          
                             //Create Email Headers
                             $headers = array (
                               'From' => $sender,
                               'Reply-To' => $sender,
                               'Return-Path' => $sender,
                               'Subject' => $subject
                             );
                          
                             //Create Email Body (HTML)
                             $bodyhtml = "<html>\r\n<body>\r\n<p>Dear $firstname $lastname,</p>\r\n<p>Here is my HTML Email / Used for Meeting Description</p>\r\n</body>\r\n</html>";
                          
                             //Create ICAL Content (Google rfc 2445 for details and examples of usage)
                             $ical = "BEGIN:VCALENDAR
                          PRODID:-//Google Inc//Google Calendar 70.9054//EN
                          VERSION:2.0
                          CALSCALE:GREGORIAN
                          METHOD:PUBLISH
                          BEGIN:VEVENT
                          DTSTART:20110110T110000Z
                          DTEND:20110110T120000Z
                          DTSTAMP:20110109T010919Z
                          UID:sjt64vqadlhlb1j8edi18oeelo@google.com
                          CREATED:20110110T093149Z
                          DESCRIPTION:
                          LAST-MODIFIED:20110110T093149Z
                          LOCATION:
                          SEQUENCE:0
                          STATUS:CONFIRMED
                          SUMMARY:Yes it works
                          TRANSP:OPAQUE
                          END:VEVENT
                          END:VCALENDAR";
                          
                             // Create the Mime message object
                             $mime = new Mail_mime('\r\n');
                          
                             // Add the HTML to the object
                             $mime->setHTMLBody($bodyhtml);
                          
                             // Add the attachment
                             $file_name = "dispatch.ics";
                             $content_type = "text/calendar";
                             $mime->addAttachment ($ical, $content_type, $file_name, 0);
                          
                             // Get the MIME message
                             $body = $mime->get();
                             $headers = $mime->headers($headers);
                          
                             // Create an SMTP object
                             $mail =& Mail::factory("smtp", $smtp_params);
                          
                             // Send the message
                             //echo $mail->send($recipient, $headers, $body);
                             return ($mail->send($recipient, $headers, $body) === 1) ? TRUE : FALSE;
                           }
                          

                          Thanks for all your help. I fully understand that there is only so much you can do without actually going onto the server. I've shouted many times at this thing! (Sorry, had to do 2 replies as character limit)

                            What error message do you get back from the second script?

                            You have an extra $ here:

                            $recipient = "$$email";

                            which will be causing A problem, even if it's not THE problem...

                              You can add

                              'debug' => TRUE

                              to the $smtp_params array to turn on debugging in the PEAR class

                                DaveRandom;10973046 wrote:

                                What error message do you get back from the second script?

                                You have an extra $ here:

                                $recipient = "$$email";

                                which will be causing A problem, even if it's not THE problem...

                                Ok, took that part out and this is the code now... (changed from echo $mail to return)

                                	//$firstname is the first name of target
                                	//$lastname is the last name of target
                                	//$email is the targets email address
                                	//$meeting_date is straight from a DATETIME mysql field and assumes UTC.
                                	//$meeting_name is the name of your meeting
                                	//$meeting_duretion is the duration of your meeting in seconds (3600 = 1 hour)
                                	$firstname = "John";
                                	$lastname = "Smith";
                                	$email = "richcranney@googlemail.com";
                                	$meeting_date = "2011-02-25 13:40:00"; //mysql format
                                	$meeting_name = "Hello";
                                	$meeting_duration = 3600;
                                
                                //returns true or false
                                $result = sendIcalEmail($firstname,$lastname,$email,$meeting_date,$meeting_name,$meeting_duration);
                                
                                //display result
                                if($result) {
                                	echo "Email sent successfully.";
                                } else {
                                	echo "A problem occured sending email";
                                }
                                
                                
                                
                                require_once('/usr/local/lib/php/Mail/mimePart.php');
                                
                                ///usr/local/lib/php/Mail/mime.php
                                 function sendIcalEmail ($firstname,$lastname,$email,$meeting_date,$meeting_name,$meeting_duration) {
                                require_once('Mail.php');
                                require_once('Mail/mime.php');
                                   // Data about the sender & email
                                   $from_name = "My Name";
                                   $from_address = "test@richardcranney.com";
                                   $subject = "Meeting Booking"; //Doubles as email subject and meeting subject in calendar
                                   $meeting_description = "Here is a brief description of my meeting\n\n";
                                   $meeting_location = "My Office"; //Where will your meeting take place
                                
                                   // SMTP details
                                   $smtp_params = array (
                                     "host" => "localhost",
                                     "port" => 25,
                                     "auth" => TRUE,
                                     "username" => "test@richardcranney.com",
                                     "password" => "******"
                                   );
                                
                                   //Convert MYSQL datetime and construct iCal start, end and issue dates
                                   $meetingstamp = strtotime($meeting_date . " UTC");
                                   $dtstart= gmdate("Ymd\THis\Z",$meetingstamp);
                                   $dtend= gmdate("Ymd\THis\Z",$meetingstamp+$meeting_duration);
                                   $todaystamp = gmdate("Ymd\THis\Z");
                                
                                   //Create unique identifier
                                   $cal_uid = date('Ymd').'T'.date('His')."-".rand()."@mydomain.com";
                                
                                   // Build sender/recipient in the form PEAR::Mail wants them
                                   $sender = "$from_address";
                                   $recipient = "$email";
                                
                                   //Create Email Headers
                                   $headers = array (
                                     'From' => $sender,
                                     'Reply-To' => $sender,
                                     'Return-Path' => $sender,
                                     'Subject' => $subject
                                   );
                                
                                   //Create Email Body (HTML)
                                   $bodyhtml = "<html>\r\n<body>\r\n<p>Dear $firstname $lastname,</p>\r\n<p>Here is my HTML Email / Used for Meeting Description</p>\r\n</body>\r\n</html>";
                                
                                   //Create ICAL Content (Google rfc 2445 for details and examples of usage)
                                   $ical = "BEGIN:VCALENDAR
                                PRODID:-//Google Inc//Google Calendar 70.9054//EN
                                VERSION:2.0
                                CALSCALE:GREGORIAN
                                METHOD:PUBLISH
                                BEGIN:VEVENT
                                DTSTART:20110110T110000Z
                                DTEND:20110110T120000Z
                                DTSTAMP:20110109T010919Z
                                UID:sjt64vqadlhlb1j8edi18oeelo@google.com
                                CREATED:20110110T093149Z
                                DESCRIPTION:
                                LAST-MODIFIED:20110110T093149Z
                                LOCATION:
                                SEQUENCE:0
                                STATUS:CONFIRMED
                                SUMMARY:Yes it works
                                TRANSP:OPAQUE
                                END:VEVENT
                                END:VCALENDAR";
                                
                                   // Create the Mime message object
                                   $mime = new Mail_mime('\r\n');
                                
                                   // Add the HTML to the object
                                   $mime->setHTMLBody($bodyhtml);
                                
                                   // Add the attachment
                                   $file_name = "dispatch.ics";
                                   $content_type = "text/calendar";
                                   $mime->addAttachment ($ical, $content_type, $file_name, 0);
                                
                                   // Get the MIME message
                                   $body = $mime->get();
                                   $headers = $mime->headers($headers);
                                
                                   // Create an SMTP object
                                   $mail =& Mail::factory("smtp", $smtp_params);
                                
                                   // Send the message
                                   //echo $mail->send($recipient, $headers, $body);
                                   return ($mail->send($recipient, $headers, $body) == 1) ? TRUE : FALSE;
                                 }

                                I now get an email, still in my SPAM with all the AntiAbuse things on it 🙁 Which is what I was trying to get away from by doing this.

                                The email doesn't hold the correct attachment either, it has come through as noname. Thats it.

                                  The AntiAbuse headers will always be there, even if the message is not considered spam. This is simply the spam filter letting the rest of the world know it has done it's job.

                                  I think the best thing to do here would be to go back a few versions, to where the only problem was the fact it was being spammed, and leave it for now - come back to it in a week or so when there has been some time to mull it over.

                                  If you are sending with SMTP auth, there is no real reason for this not to work.

                                  Do me a favour, try it with the SMTP details I will PM you with in a minute...

                                    DaveRandom;10973049 wrote:

                                    The AntiAbuse headers will always be there, even if the message is not considered spam. This is simply the spam filter letting the rest of the world know it has done it's job.

                                    I think the best thing to do here would be to go back a few versions, to where the only problem was the fact it was being spammed, and leave it for now - come back to it in a week or so when there has been some time to mull it over.

                                    If you are sending with SMTP auth, there is no real reason for this not to work.

                                    Do me a favour, try it with the SMTP details I will PM you with in a minute...

                                    Tried it with those settings, think its timed out again. Thanks.

                                    The Anti Abuse don't appear in other emails I receive, not sure why...

                                    Delivered-To: richcranney@googlemail.com
                                    Received: by 10.204.32.133 with SMTP id c5cs42270bkd;
                                            Sun, 23 Jan 2011 09:32:23 -0800 (PST)
                                    Received: by 10.42.174.65 with SMTP id u1mr3628644icz.55.1295803942033;
                                            Sun, 23 Jan 2011 09:32:22 -0800 (PST)
                                    Return-Path: <iworld@webg11.iworld.com>
                                    Received: from webg11.iworld.com (webg11.iworld.com [63.236.18.146])
                                            by mx.google.com with ESMTP id jv9si28889706icb.123.2011.01.23.09.32.21;
                                            Sun, 23 Jan 2011 09:32:22 -0800 (PST)
                                    Received-SPF: pass (google.com: best guess record for domain of iworld@webg11.iworld.com designates 63.236.18.146 as permitted sender) client-ip=63.236.18.146;
                                    Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of iworld@webg11.iworld.com designates 63.236.18.146 as permitted sender) smtp.mail=iworld@webg11.iworld.com
                                    Received: (from iworld@localhost)
                                    	by webg11.iworld.com (8.11.6/8.11.6) id p0NHWOi23774;
                                    	Sun, 23 Jan 2011 12:32:24 -0500
                                    Date: Sun, 23 Jan 2011 12:32:24 -0500
                                    To: richcranney@googlemail.com
                                    Subject: New Private Message at PHPBuilder.com
                                    From: "PHPBuilder.com" <jpalermo@internet.com>
                                    Auto-Submitted: auto-generated
                                    Message-ID: <20110123173220.6e0110594920@phpbuilder.com>
                                    MIME-Version: 1.0
                                    Content-Type: text/plain; charset="ISO-8859-1"
                                    Content-Transfer-Encoding: 8bit
                                    X-Priority: 3
                                    X-Mailer: vBulletin Mail via PHP

                                      It will be the OUTGOING server that adds the X-AntiAbuse headers, passing through it's own anti-spam processes. Well, it could be anywhere really, but if you get other messages into GoogleMail that don't have them, it's not Google that are adding them.

                                      It can be a real pain in the a**e all of this buisness, and I try to avoid getting involved with it, but I do know I have had something very close to the code above working before, for something I wrote a while ago. I have a suspiscion that, since you have had timeout's for both your own domain name and mine, the DNS on your hosting server is not configured right.

                                      You could try using 66.7.194.3 instead of mail.net... that I sent you for the 'host' parameter...