Forum Moderators: coopster

Message Too Old, No Replies

PHP mail question

         

lZakl

3:38 am on Dec 3, 2004 (gmt 0)

10+ Year Member



Hello out there! I am pretty new to PHP and have really just started getting into it. I have been using PERL for about 4 years and I have used ASP on and off for about 3, so I am picking it up fairly easily.

I have a website for a small business (publishing), and would like people to be able to go to my site and submit for advertisements in our weekly paper. Now I wanted this to be an all-in-one kind of thing, it will take them to an SSL directory where it will take their personal info, billing and Credit Card, AND (this is the part I can't get to work) an attachment (PDFs, Jpgs, Docs, mainly). Now I've tried several different mail forms, and all of them (some with a little tweeking), send the message with no attachment. Now before we start troubleshooting, some things needs to be said, because I have a haunch that it has something to do with:

1) I am using Yahoo! web hosting
2) Yahoo! will not allow the FROM address to be from any other domain except that which is doing the sending
3) Can only send 250 per day

You get where I am going with this? What other limitations does Yahoo! hosting have? I wonder if there is a ban on all PHP mail attachments from this host? If not, then I am stumped, as I have tried mail(), Mime, even Pear... I called Yahoo! and simply asked them if they support attachments, and you know what they said? "We don't support PHP help requests, visit the php website for support". There you have it, in other words... "Ummmm, that's not in my book here, and when I type in your problem on my computer I don't get any results. I'm just a flunky who has no idea what you're talking about, so... I guess call the php people, they'll know what WE support."

any input would be GREATLY appreciated!

[edited by: coopster at 3:49 pm (utc) on Dec. 3, 2004]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]

jamie

11:47 am on Dec 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi lZakl

welcome to webmasterworld! :)

not quite what you asked, but are you going to be encrypting the personal info (and especially the credit card info) before sending it by email?

the reason i ask is that just because it is entered in ssl, doesn't mean it is ecnrypted between the ssl server and your inbox. pgp would be one way to do it. (if you have thought about this then please ignore ;-)

re: the mailing: have you tried using a ready made class (not re-inventing the wheel, etc). phpmailer is a good one, which makes it very easy to send attachments, etc. i think you'd first of all have to store the soon-to-be-attached files in a directory somewhere before actually sending them. although someone may come up with a better idea?

hope that helps a bit

Bonusbana

12:45 pm on Dec 3, 2004 (gmt 0)

10+ Year Member



phpmailer class is the best, and I have tried quite a few. Give it a shot.

jamie

2:05 pm on Dec 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



bonusbana,

just as an off topic - i have never succeeded in sending a CC with phpmailer - have you ever had that problem?

cheers

lZakl

5:13 pm on Dec 3, 2004 (gmt 0)

10+ Year Member



Thanks! I'll give that a shot... The problem that I am having (before I get all caught up trying to encrypt ... I'll get into that mess later) is sending with an attachment. I can send if the message contains no attachment, and cannot if it contains one. I have failed in my error handling to pinpoint the reason ... and I am unsure as to whether Yahoo! allows this, or I am simply not doing it correctly. I am going to give the class a try right now! I appreciate your input!

jamie,

I read in the class the following; it may, or may not be relevant to the reason you can't get CC to work, but just the same, I thought I'd share:

* Adds a "Cc" address. Note: this function works
* with the SMTP mailer on win32, not with the "mail"
* mailer.

lZakl

6:20 pm on Dec 3, 2004 (gmt 0)

10+ Year Member



O.k. I used the phpmailer, and it sent just as all the rest did... Without attachment. This is the PHP I used to send a test message to myself. I am going to try to use my local smtp host using $mail->IsSMPT(); next. Being able to do this allows me to troubleshoot whether Yahoo! is the culprit! I am a little excited at this revalation as I just realized it while writing this, sorry...


<?php
require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSendmail(); // set mailer to use Sendmail

$mail->From = "return@my other domain.net";
$mail->FromName = "Mailer";
$mail->AddAddress("me "zak" @mydomain.com"); // name is optional

$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->AddAttachment("/Users/zak/Desktop/libmail.txt"); // add attachments
// $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML

$mail->Subject = "This is a test!";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
else
{
echo "Message has been sent";
}
?>

lZakl

6:31 pm on Dec 3, 2004 (gmt 0)

10+ Year Member



Yet another update, the SMTP failed to connect. The server requires AUTH, and I'm sure all my info was correct... I gave me this message


Message could not be sent.

Mailer Error: Language string failed to load: connect_host

Oh well, it was worth a shot :0)

jamie

9:41 am on Dec 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi lZakl

thanks for pointing out that Cc limitation. i'll look into that.

sorry you can't seem to get yours working.

sonjay

1:38 pm on Dec 5, 2004 (gmt 0)

10+ Year Member



IZakl, I have to wonder if the attachment is being successfully uploaded to the server. Have you investigated that end of things? Maybe you should (temporarily) modify your script so that it saves the attachment to a designated directory on your server and sends you an e-mail with the name of the attachment. Then ftp in and see if the attachment is there. That way you can at least determine if the attachment is actually present.

If it's not, then your problem isn't with sending the attachment, it's with uploading the attachment.

lZakl

11:49 am on Dec 6, 2004 (gmt 0)

10+ Year Member



sonjay,

That's a good troubleshooting step! I will try that a little later on today and let you know how it goes... Thanks!

lZakl

2:01 pm on Dec 6, 2004 (gmt 0)

10+ Year Member



My findings from sonjay's suggestion....

1) I created a simple HTML form for upload...

[code]
<form enctype="multipart/form-data" action="upload.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

[\code]


2) I created a simple php to proccess it.. (I also substituted $_FILES with $HTTP_POST_FILES as per the php website incase I had a earlier version I was dealing with and it made no difference)

[code]
<?php
$uploaddir = 'load/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
echo "File is valid, and was successfully uploaded.\n";
}

else
{
echo "Why didn't you upload, you SOB?!<br><br>\n";
}

echo 'Here is some more debugging info:<br><br>';
print_r($_FILES);
echo "Loadfile is: $uploadfile<br>";
echo "LoadDir is: $uploaddir<br>";
?>
[\code]


3) And finally the output of the process. It seems as though I can't upload files... hhhmmmm This is the output from the above php file.

[code]
Why didn't you upload, you SOB?!

Here is some more debugging info:

Array ( ) Loadfile is: load/
LoadDir is: load/
[\code]