0

Hello guys I am working on webapplication for sending multimedia messages upon user input of their phone numbers. I am successfully able to send emails with images in HTML form. Now, I am trying to send my customers MMS via PHP mail function, but the only thing they receive is the link that I send them with the message. Here is what I have come up with so far.

<?php
$email = '1234567890@somenetwork.domain'; 
$link = $_COOKIE["coupon"];
$to = $email;
$subject = 'Some Subject';
$message = " Hello, This is Testing Text 8.0 
            <a href=\"https://encrypted-tbn0.gstatic.com/images?           \     
             q=tbn:ANd9GcS0dA2aipmy9hwAitgD8U5n8l_afNBvxYc3gnOFi7hOGoGAGIHssw\">Your Link</a>  ";

$message->addAttachment("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS0dA2aipmy9hwAitgD8U5n8l_afNBvxYc3gnOFi7hOGoGAGIHssw", "image/gif"); 
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: someone <support@someone.com>' . "\r\n";
mail($email, $subject, $message, $headers);

?>
  • 1
    not all cell provider email to sms\mms services support images. I would look at an SMS Gateway Provider –  Jun 11 '13 at 02:08
  • 2
    Possible duplicate of [Send attachments with PHP Mail()?](http://stackoverflow.com/questions/12301358/send-attachments-with-php-mail) – Mogsdad May 07 '16 at 14:07

2 Answers2

2

When sending to a phone as MMS, you have to send the image as an attachment.

I found the following answer to be very helpful for easily sending attachments, even though it references "mail", not MMS: Send attachments with PHP Mail()?

Community
  • 1
  • 1
NRW
  • 51
  • 1
  • 5
  • The questions (and the answers) are not actually duplicates. My answer is the first sentence: send as attachment (instead of sending a reference, as the question suggests). The link I included as a courtesy: an example of how to send an attachment. Should I not include the link, make him search for an attachment method on their own? (Sorry if I should know this; I am quite new here) – NRW May 11 '16 at 15:20
  • Thanks for clarifying that - I've made a minor edit to your answer to separate the reference material a bit. Cheers! – Mogsdad May 11 '16 at 15:24
1

One of the issues is that you can't fetch that image in that fashion. I.e. https://encrypted-tbn0.gstatic.com/images?\ q=tbn:ANd9GcS0dA2aipmy9hwAitgD8U5n8l_afNBvxYc3gnOFi7hOGoGAGIHssw

returns an empty file.

Also, since when can you send MMS via PHP's mail() function?

The most reliable way in my experience to send images via SMS/MMS is to send a WAP push msg.

Rid Iculous
  • 3,696
  • 3
  • 23
  • 28
  • many cell provides have a gateway so you can email to sms to clinets on their network –  Jun 11 '13 at 02:20
  • for a fact i know verizon and att does support what I am trying to do – Sadjka Dssdflsdkjf Jun 11 '13 at 02:30
  • In none of these cases the *PHP function* mail() sends out a SMS message. – Rid Iculous Jun 11 '13 at 04:03
  • Please provide the syntax of the command for this scenario: I want to send an SMS saying "hello" to 0061401493021. How do I do that using PHP mail()? – Rid Iculous Jun 11 '13 at 04:13
  • @RidIculous, I think an SMS gateway would usually accept a `To` field in the form `0061401493021@smsgateway.tld`. I imagine the SMS text would be in the body of the message with a discarded title, but that's probably gateway-dependent. However, if your question is "Does the `mail()` function send an SMS itself", then you are correct; the answer is no. – halfer Jul 09 '13 at 19:03
  • outside the US most gateways do not accept a phone number as a relay parameter. Any gateway that does will have its own syntax and transport definitions as to how embed data and specify recipients. All of this is completely independent of the PHP specific mail() function. Which is probably why this question has been down-voted already. – Rid Iculous Jul 15 '13 at 09:43
  • PHP can in fact send MMS. I've been doing it for years. Your headers have to be correct for sending data. – Ben Racicot Jun 22 '14 at 18:11
  • @BenRaicot: Please provide the syntax of the command for this scenario: I want to send an SMS saying "hello" to 0061401493021. How do I do that using PHP mail()? What headers do I set. Amazing that this functionality exists for years, but people are still using web2mobile gateways. – Rid Iculous Jun 22 '14 at 22:47