PHP Forums Archive

PHP attachment mailer class won't send mail without at least 1 attachment.

Tags: attachment, php class

jimbell posted on 2010-01-12 17:43:51 #

I have a form for club members to send an email. The members might want to send a text only email with no attachment, or a email with an attachment.
The class works perfectly when send mail with 1 or more attachments, but when I send the mail with no attachment, the email never arrives. I am testing with the "attach_mailer_example.php". When I comment out the 2 "add_attach_file" lines and execute the script, the page displays "mail successfully submitted", but the mail never arrives. When I un-comment the "add_attach_file", the mail is sent and arrives immediately.
I look at the code in the class and it appears that it is supposed to work without attachments. Any ideas?

Comments / discussions

Olaf posted on 2010-01-12 19:44:35 #

hello Jim,

the class is a result of some study and never left the early beta status.
I used the class in several applications with and without attachments.

do you use different code for both cases? Which code do you use in both cases?

jimbell posted on 2010-01-12 23:23:52 #

Hi Olaf

Here is a cut & paste from the actual code that works.

<?php
// send mail without attachment
require("attach_mailer_class.php");
$test = new attach_mailer($name = "Jim", $from = "jim@jimbell.us", $to = "jim@jimbell.us", $cc = "", $bcc = "", $subject = "Test text email with attachments");
$test->text_body = "...Some body text\n\n the admin";
$test->add_attach_file("cpc logo.jpg");
$test->process_mail();

?>

Here is the code that does not work. The program runs without an error, but I never get the email

<?php
// send mail without attachment
require("attach_mailer_class.php");
$test = new attach_mailer($name = "Jim", $from = "jim@jimbell.us", $to = "jim@jimbell.us", $cc = "", $bcc = "", $subject = "Test text email with attachments");
$test->text_body = "...Some body text\n\n the admin";
//$test->add_attach_file("cpc logo.jpg");
$test->process_mail();

?>

As you can see, I just commented out the "add_attach_file" statement.
Thanks

Olaf posted on 2010-01-13 05:33:51 #

Do you tried to send the same mail to other email addresses? Maybe to some gmail account?