Email Frustrations

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Does this work without verification?
smtp.npsis.com
And you said that if you try to send a e-mail using mail() like this->

Code: Select all

<?php
<?php 
mail("YOURADDRESS","SUBJECT","MESSAGE");  
?> 
?>
WHERE "YOURADDRESS" is your e-mail address it doesn't send the e-mail to you. If that's the case the PHP is not configured properly to send e-mails.
dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Post by dgarrett »

yeah that works, even works with a variable in the, to, part, but if the bidy contains a variable it does not. What would happen instead of putting the $body variable in the mail finction, I was to put echo $body, same thing I imagine. It just does not like the contents of the body variable is my conclusion, what I can't seem to figure out...... I really don't want to use asp but I may be forced to here, and I really don't like asp, but have been ablr to make it work in the past -dustin
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Code: Select all

<?php
$ToEmail = "dustingarrett@yahoo.com";
$ToName = "Dustin";
$ToSubject = "New Remedy Motel Mailing List Entry";

$EmailBody = "'Sent By:' $FirstName 'Senders Email:' $Email 'Address:' $Address";

//$EmailFooter="This message was sent by: $FirstName  If you feel that you
//recieved this e-mail by accident please contact us at http://www.whitedotgroup.com";

//$Message = $EmailBody
//.$EmailFooter;

if ( mail($ToName, $ToSubject, $EmailBody, "From: ".$FirstName." <".$Email.">") ) {
    echo 'I worked';
} else {
    echo 'I did not work';
}
Print "_Root.Mail.EmailStatus=Complete - Your mail has been sent";
?>
Try that...

Also, doing mail('string', 'etc', 'etc') doesn't work...it just doesn't throw up an error.

And, as a note, you only put an email into the email argument, not that funky brackets you had as well you had going on
dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Post by dgarrett »

OK- This is a step in the right direction, error checking is great, wish I would have come up with this earlier, or myself for that matter. Thanks. SO the above code is in action and I get this responce. Unfortunatly.
Warning: Bad Message destination in U:\users\r\remedy\pages\dust_mail.php on line 14
I did not work
So again I am not shure what to do.

This is the URL I am entering manually to get the results
Could there be a URL encoding promblem with my manually entered variable in the address bar?
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Code: Select all

<?php
$ToEmail = "dustingarrett@yahoo.com";
$ToName = "Dustin";
$ToSubject = "New Remedy Motel Mailing List Entry";

$EmailBody = "'Sent By:' $FirstName 'Senders Email:' $Email 'Address:' $Address";

//$EmailFooter="This message was sent by: $FirstName  If you feel that you
//recieved this e-mail by accident please contact us at http://www.whitedotgroup.com";

//$Message = $EmailBody
//.$EmailFooter;

if ( mail($ToEmail, $ToSubject, $EmailBody, "From: ".$FirstName." <".$Email.">") ) {
    echo 'I worked';
} else {
    echo 'I did not work';
}
Print "_Root.Mail.EmailStatus=Complete - Your mail has been sent";
?>

Ooops, I had $ToName where there should have been $ToEmail.
dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Post by dgarrett »

Thank you so much... It has finally worked. Even from flash. The code does not seem all too different from the original code I was working with in the begining. When use use mail() do you have to use variables? Can you just enter text. ie mail("dustin@dustin.net", "subject", "Body text");... Anyhow I am ever so grateful for the help -Dustin
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

You can use either variables or constant strings, it doesn matter. The problem was this line in your original code:

Code: Select all

mail($ToName." <".$ToEmail.">", $ToSubject, $EmailBody, "From: ".$FirstName." <".$Email.">");
In particular, you had this as the first argument:

Code: Select all

$ToName." <".$ToEmail.">"
So basically, you were sending mail() a email address like this:

Jason Lotito <jason@devnetwork.net>

And we all know that isn't a real email address. You just had to remove all that extra stuff and leave in the email address. :D
Post Reply