Brian W Posted November 20, 2008 Share Posted November 20, 2008 Hi people, I want to know if there is a way to customize the error messages or completely negate the errors that come from mail(). For example: PHP Warning: mail(): SMTP server response: 550 I'd just want it to say "Error: Your message was not sent" or I'd even be happy with it not doing anything and just carrying on with the rest of my script. Also, sometimes I encounter Gray listing issues. Is there a way I could get it to complete the emailing process to everyone else even if one person is gray listing me? Plus, I'm getting this error PHP Warning: mail(): SMTP server response: 550 <<*my email*@gmail.com> No such user here in *line where I have mail($to, $subject, $body)* When I try sending to anyone not w/in the SMTP that my work uses (mail.ourdomain.com) For example, "[email protected]" works, but when I try sending to g-mail or yahoo I get an that error above. Server this is running off of is: *Windows Server 2008 *IIS 7 *PHP 5.2.6 as Fast CGI Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/133521-mail-help/ Share on other sites More sharing options...
monkeytooth Posted November 20, 2008 Share Posted November 20, 2008 To turn off that error, and well all errors in general that will run within this portion of your script add error_reporting(0); somewhere within your php (above the mail code in this instance, below will negate the reason for it being there). as for changing the error code, cant, hence why we are turning it off.. My suggestion would be from here.. alter your mail code to look similar to this if(mail($to, $subject, $message, "From: $from")) echo "Mail sent"; else echo "Mail send failure - message not sent"; ?> of course you can have all the mail code your doing now, but just wrap the if-else brackets around it like above.. and give that a whirl. Link to comment https://forums.phpfreaks.com/topic/133521-mail-help/#findComment-694472 Share on other sites More sharing options...
iversonm Posted November 20, 2008 Share Posted November 20, 2008 turn it into an if statement <?php if(isset($_POST['data'])){ $mail=mail($_POST['blah'], $_POST['again']...); if($mail){ echo 'Mail was sent successfully'; }else{ echo 'Sending failed } something like that would work, for my sites i actually make a form class but that might be unessesary not sure about your other problem Link to comment https://forums.phpfreaks.com/topic/133521-mail-help/#findComment-694474 Share on other sites More sharing options...
monkeytooth Posted November 20, 2008 Share Posted November 20, 2008 Oh and to touch on the domain.com vs. gmail.com issue.. Thats one of 2 things in my mind, could be wrong though.. 1st, your hosting company set their servers up to tempt and block spoofed emails coming through the mail() function.. or.. You are tempting to send SSL email.. and that be the case then you do need to port all out going through an actual account thats on your hosting plan. As sending mail through SSL requires authentication user/pass combo for the email to send it.. and theres a diffrent way to send mail with the mail() function when it involves SSL its pretty much adding a couple extra variables and setting up the send part of the mail to also include a user/pass for the box sending it. Link to comment https://forums.phpfreaks.com/topic/133521-mail-help/#findComment-694482 Share on other sites More sharing options...
Brian W Posted November 20, 2008 Author Share Posted November 20, 2008 Thanks guys, I'll use the error_reporting(0) thing, thanks. My mail function looks like this if(!mail($To, $Subject, $Body)) { echo "Error: there was a problem sending mail.";} But it doesn't use my error message, maybe it will when I set the error_reporting... 1) I read somewhere a little comment about setting your SMTP to "rout" ( think the work was "rout", maybe not) emails. Think that has anything to do with it? Btw, we host our own IIS, Email, SQL, and MySQL all in house.The IIS Server: Processor: Intel® Xeon® CPU E5430 @ 2.66GHz 2.66 GHz (2 processors) [english: 2 quadcores] Memory: 8.00 GB The SQL/MySQL server and our Mail server have same processing but less ram. 2)I'll look into if we are sending using SSL. Do you an example of how to use the "send part" or a link to some reading material? Again, thanks. Link to comment https://forums.phpfreaks.com/topic/133521-mail-help/#findComment-694505 Share on other sites More sharing options...
Brian W Posted November 20, 2008 Author Share Posted November 20, 2008 Okay, error_reporting(0); keeps it from showing the errors, but it still doesn't send to the recipients that should work. example: ... $To = "person <[email protected]>, me <[email protected]>"; error_reporting(0); if(!mail($To, $Subject, $Body)) { echo "Error: there was a problem sending mail."; } The email should deliver to the second address because it works when it is only sending to that address, right? If that isn't correctable, I'll turn the emails into an array and run the mail function individually for each address. Pain, but that should negate the problem. Link to comment https://forums.phpfreaks.com/topic/133521-mail-help/#findComment-694528 Share on other sites More sharing options...
Brian W Posted November 20, 2008 Author Share Posted November 20, 2008 Okay, by sending the emails using a loop (apparently the same way spammers do :-) I was able to get it to send to the emails that work and create an error report of the emails that don't work. This really doesn't help the end product but it makes testing easier. I'm still trouble shooting why it won't send to people outside of my SMTP (assumed that is the reason). I have not had this problem ever before with any other mail servers so I don't even know what to look for. I looked into PEAR... need to do some more reading and probably ask questions in the appropriate forum for that thing but I doesn't like me so I don't like it so far. I follow the tutorial on their site and things don't add up as they say they should. oye Any more input is appreciated. Link to comment https://forums.phpfreaks.com/topic/133521-mail-help/#findComment-694670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.