473,382 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Sending message to email address like yahoomail/google mail? (Email notification-php)

Exequiel
288 256MB
hello friends, I just want to ask if how i can send a message to any email address like yahoomail/googlemail after i submit the form,

example emails:
exezick143@gmail.com // google mail,
exezick_85@yahoo.com //yahoo mail

message to send:
sender_name has been replied to your message.
to view it please go to: www.mypage.com/reply_message/ - (this is just a sample link)


Expand|Select|Wrap|Line Numbers
  1. public function save_reply()
  2. {
  3.     $theuser = $_POST['theuser'];
  4.     $deskid = $_POST['deskid'];
  5.     $message_reply = mysql_real_escape_string($_POST['message_reply']);
  6.             $today = date("m/d/Y h:i:s a");
  7.             session_start();
  8.             $files = (isset($_SESSION['uploadedIMG']))?$_SESSION['uploadedIMG']:'';
  9.  
  10.             $assigned = mysql_fetch_array(mysql_query("SELECT * FROM across_help_desk WHERE help_desk_id='$deskid'"));
  11.  
  12.             $insert_reply = mysql_query("INSERT INTO across_help_confirm_message(help_desk_id,assigned,reply_message,sender,sender_status,message_status,attach,date) VALUES('$deskid','$assigned[assigned]','$message_reply','$theuser','1','1','$files','$today')"); 
  13.  
  14.             /*
  15.                 code for sending message to email address.
  16.                 example emails: 
  17.                     exezick143@gmail.com // google mail,
  18.                     exezick_85@yahoo.com //yahoo mail
  19.                 message to send: 
  20.                     sender_name has been replied to your message.
  21.                     to view it please go to: www.mypage.com/reply_message/ - (this is just a sample link)
  22.             */
  23.  
  24.         if($insert_reply)
  25.         {
  26.             $bi = 0;
  27.             $ass = mysql_query("SELECT * FROM across_help_confirm_message WHERE help_desk_id='$deskid'");
  28.             $count_help_id = mysql_num_rows($ass);
  29.             $count_help_id = $count_help_id - 1;
  30.             while($up_message = mysql_fetch_array($ass))
  31.             {
  32.                 if($bi < $count_help_id)
  33.                 {
  34.                     $mess_up = mysql_query("UPDATE across_help_confirm_message SET message_status='2' WHERE help_desk_id='$deskid' AND confirm_message_id='$up_message[confirm_message_id]'");
  35.                 }
  36.                 $bi++;
  37.  
  38.             }
  39.  
  40.             if($mess_up)
  41.             {
  42.                 echo 1;//successfully send
  43.             }
  44.         }
  45.         else
  46.         {
  47.             echo 0;    //not send
  48.         }
  49.     }
  50.  
  51.  
any reply is appreciated. . .:) thank you :)
Attached Images
File Type: jpg chat box.jpg (29.3 KB, 259 views)
Sep 18 '13 #1
4 1929
The last variation that we will consider is email with attachments. To send an email with attachment we need to use the multipart/mixed MIME type that specifies that mixed types will be included in the email. Moreover, we want to use multipart/alternative MIME type to send both plain-text and HTML version of the email. Have a look at the example:



Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. //define the receiver of the email 
  3. $to = 'youraddress@example.com'; 
  4. //define the subject of the email 
  5. $subject = 'Test email with attachment'; 
  6. //create a boundary string. It must be unique 
  7. //so we use the MD5 algorithm to generate a random hash 
  8. $random_hash = md5(date('r', time())); 
  9. //define the headers we want passed. Note that they are separated with \r\n 
  10. $headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com"; 
  11. //add boundary string and mime type specification 
  12. $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; 
  13. //read the atachment file contents into a string,
  14. //encode it with MIME base64,
  15. //and split it into smaller chunks
  16. $attachment = chunk_split(base64_encode(file_get_contents('attachment.zip'))); 
  17. //define the body of the message. 
  18. ob_start(); //Turn on output buffering 
  19. ?> 
  20. --PHP-mixed-<?php echo $random_hash; ?>  
  21. Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" 
  22.  
  23. --PHP-alt-<?php echo $random_hash; ?>  
  24. Content-Type: text/plain; charset="iso-8859-1" 
  25. Content-Transfer-Encoding: 7bit
  26.  
  27. Hello World!!! 
  28. This is simple text email message. 
  29.  
  30. --PHP-alt-<?php echo $random_hash; ?>  
  31. Content-Type: text/html; charset="iso-8859-1" 
  32. Content-Transfer-Encoding: 7bit
  33.  
  34. <h2>Hello World!</h2> 
  35. <p>This is something with <b>HTML</b> formatting.</p> 
  36.  
  37. --PHP-alt-<?php echo $random_hash; ?>-- 
  38.  
  39. --PHP-mixed-<?php echo $random_hash; ?>  
  40. Content-Type: application/zip; name="attachment.zip"  
  41. Content-Transfer-Encoding: base64  
  42. Content-Disposition: attachment  
  43.  
  44. <?php echo $attachment; ?> 
  45. --PHP-mixed-<?php echo $random_hash; ?>-- 
  46.  
  47. <?php 
  48. //copy current buffer contents into $message variable and delete current output buffer 
  49. $message = ob_get_clean(); 
  50. //send the email 
  51. $mail_sent = @mail( $to, $subject, $message, $headers ); 
  52. //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
  53. echo $mail_sent ? "Mail sent" : "Mail failed"; 
  54. ?>

As you can see, sending an email with attachment is easy to accomplish. In the preceding example we have multipart/mixed MIME type, and inside it we have multipart/alternative MIME type that specifies two versions of the email. To include an attachment to our message, we read the data from the specified file into a string, encode it with base64, split it in smaller chunks to make sure that it matches the MIME specifications and then include it as an attachment.
Sep 18 '13 #2
you can do more than it.. just follow the link..

http://www.phpjabbers.com/make-conta...php-php21.html
Sep 18 '13 #3
Exequiel
288 256MB
I used this codes for code igniter, but it still doesn't work. . the link that youve gave is cool, but it still doest work when i tried it. . thank you for the reply Aurangzeb :)

$this->load->library('email');
$this->email->from('across.ph');
$this->email->to("exezick143@gmail.com");
$this->email->subject('subject');
$this->email->message('sender_name has been replied to your message.');
$this->email->send();
Sep 18 '13 #4
your welcome bro...:p
Sep 18 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: vishal | last post by:
how can i verify the email address entered by client??? is there any readily available function for that in php or mysql????? else suggest me some links for verifying email address enetered...
6
by: magister | last post by:
Hi I am sending emails from my website. The from field usually is an email address, but alot of email readers also seem to be able to pickup a "from real name". I read somewhere that I can set...
8
by: CJM | last post by:
I'm trying to retrieve the users email address via ADSI in ASP. So far, I have the following code: Set oUser = GetObject("WinNT://domain/" & Request.Form("UID") & ",user") Response.Write...
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
3
by: Morris.C | last post by:
Is there a way of automatically inserting the users e-mail address into an HTML form using Javascript so that it can then be passed to a Perl script? This for an internal internet page, so I know...
1
by: Henrik Nyberg | last post by:
Here's a small method for validating email in C#. It may save you some time.. public static bool IsValidEmailAddress(string sEmail) { if (sEmail == null) { return false; } int nFirstAT =...
4
by: Mike | last post by:
Hi all, In my recent ASP.NET 2.0 appl, I need to verify that the supplied email address is valid or not. So, here's my situation: - In my <profilearea, I created <isVerifiedproperty. - Suppose a...
1
by: terry_wall | last post by:
I am trying to add a cmdButton to an Access form. I would like to click the button, look up an email address in a database table, and execute Outlook with that email address ready to send an...
3
by: =?Utf-8?B?UGhpbGlw?= | last post by:
I switched from System.Web.Mail to System.Net.Mail, however I am now reconsidering that move because if I send an email to an email address in the form john.doe@yahoo.com, I receive an error...
1
by: barmatt80 | last post by:
there is a website i was asked to look at ( i have no clue why as i have never done much web development expecially with frontpage extensions). they want to setup a form on the page that will...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.