VTS Posted March 4, 2008 Share Posted March 4, 2008 Hello, I have a program that emails me whenever it gets errors. Since I am not always able to check my email and monitor it, I figured I would set it up to send a message to my phone on the weekends whenever it has errors. My problem is that for some reason I cannot get the mail function to send messages to my phone at all. I am using my company email as the from address. Is is just that the mail function cannot send messages to vtext accounts or am I just doing something wrong? I can just change the from address to a regular email and it works just fine. I can also send the messages from my company email to my phone but anytime I try to send it with the mail function it does not work. I have tried using the function like this: mail('xxxx@vtext.com', 'subject', 'message'); and like this as well: mail('xxxx@vtext.com','subject', 'message', 'From: company_email@company.com'); I tried to search a little for this but kept getting error when searching this site so i decided to post here. Thanks in advance for the help Quote Link to comment Share on other sites More sharing options...
VTS Posted March 4, 2008 Author Share Posted March 4, 2008 UPDATE: I can send email to my company email addresses but not to any outside emails ie yahoo, hotmail, gmail. I am guessing this means I am missing some kind of information that would allow a server to see where the email is coming from. I still am not sure what I should do. Quote Link to comment Share on other sites More sharing options...
discomatt Posted March 4, 2008 Share Posted March 4, 2008 They might be filtering the message as SPAM. There are certain headers that must exist or certain servers will mark them as spam. I had a function that included all of them, but sadly it's at my home computer. If this isn't resolved by the time I get home I'll post it here. It could also be the sendmail setup on your server. It might not allow PHP/Apache/IIS to send mail to outside servers. Quote Link to comment Share on other sites More sharing options...
VTS Posted March 4, 2008 Author Share Posted March 4, 2008 Thanks. The server here is supposed to let that go through but I will check again. Quote Link to comment Share on other sites More sharing options...
haku Posted March 4, 2008 Share Posted March 4, 2008 Try using the (free) phpmailer class, and setting your mails up as SMTP mails. That will stop them from getting filtered as junk mail. Quote Link to comment Share on other sites More sharing options...
VTS Posted March 4, 2008 Author Share Posted March 4, 2008 Ok, I just checked and there is nothing on my end that is blocking any outgoing mail. I also added 'or die("could not send message")' to the end of the mail clause and when I ran it, I got the could not send message error. I will try that phpmailer class and see how that works too. Quote Link to comment Share on other sites More sharing options...
VTS Posted March 5, 2008 Author Share Posted March 5, 2008 UPDATE: I have been trying to get the PHP mailer to work since yesterday with no luck. I keep getting the error "could not connect to smtp host" Here is the code I am using: <?php require(".\\phpmailer_v2.0.0\class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = "smtp.mycomanysmtp.com"; // specify main and backup server $mail->SMTPAuth = false; // turn on SMTP authentication $mail->Username = ""; // SMTP username $mail->Password = ""; // SMTP password $mail->From = "me@mydomain.com"; $mail->FromName = "david"; $mail->AddAddress("me@mydomain.com"); $mail->AddAddress("my_yahoo@yahoo.com"); $mail->AddAddress("my_cell@vtext.com"); // name is optional $mail->AddReplyTo("me@mydomain.com"); $mail->WordWrap = 50; // set word wrap to 50 characters //$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name $mail->IsHTML(true); // set email format to HTML $mail->Subject = "Here is the subject"; $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; } echo "Message has been sent"; ?> I have tried using this funciton with and without authentication and I get the same error every time. Anyone have any ideas? Quote Link to comment Share on other sites More sharing options...
revraz Posted March 5, 2008 Share Posted March 5, 2008 Error seems obvious: could not connect to smtp host Quote Link to comment Share on other sites More sharing options...
VTS Posted March 5, 2008 Author Share Posted March 5, 2008 Well yea but I was wondering what things could be causing this. I can send email to people within the company if I just use the mail function alone but when I use this code I keep getting that error. Not sure why. Quote Link to comment Share on other sites More sharing options...
revraz Posted March 5, 2008 Share Posted March 5, 2008 Maybe pointing to the wrong smtp server? If you use mail() alone and it works, then it's pulling the SMTP server from your PHP.INI Compare them and see what is different. Quote Link to comment Share on other sites More sharing options...
haku Posted March 5, 2008 Share Posted March 5, 2008 I think it may be working for mails within your company, as the mails may not need to pass through the SMTP server to get to internal mails, because they are internal! SMTP is what is used to send them out. As for your problem - you need to make sure the SMTP server is set correctly. You may (and probably) also need to create the email address you are sending the emails from, if it doesnt already exist. You may also need to give the username and password for that account in order to send the mail. Quote Link to comment Share on other sites More sharing options...
VTS Posted March 5, 2008 Author Share Posted March 5, 2008 Ok, I fixed the cannot connect to smtp server error and now I am getting an error stating that my helo address is invalid. What am I supposed to put in there? If I don't put anything, it tells me it doesn't accept mail from my ip and to "bugger off". If I put my smtp in there, it tells me that my helo address is invalid. Quote Link to comment Share on other sites More sharing options...
revraz Posted March 5, 2008 Share Posted March 5, 2008 Why don't you just use mail() instead? Quote Link to comment Share on other sites More sharing options...
VTS Posted March 5, 2008 Author Share Posted March 5, 2008 Someone suggested that I used the phpmailer so my mail does not get filtered as junk so I started trying to use it. Quote Link to comment Share on other sites More sharing options...
haku Posted March 6, 2008 Share Posted March 6, 2008 I don't have the answer to your question (I dont really know what a HELO address is), but maybe this article can help you: http://email.about.com/cs/standards/a/smtp.htm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.