Jump to content

Using the mail function to send a message to a cell phone


VTS

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.