Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
Photo
- - - - -

Sending Mail Using Php's Mail() Function


8 replies to this topic

#1 spotok

spotok

    Newbie [ Level 2 ]

  • Members
  • 15 posts

Posted 09 February 2005 - 09:27 AM

hi, It is possible to send mail from any account to any account using the php's built in mail() function.. for which is very easy to write the coding... wt you are supposed to do is just pass the parameters like from, to, subject, message .. and attachments if any, and your email will be sent in no time.. as Astahost.com supports the php scripts you can use it if you already have an account here...==============================================Example 1. Sending mail. If a fourth string argument is passed, this string is inserted at the end of the header. This is typically used to add extra headers. Multiple extra headers are separated with a carriage return and newline. Note: You must use \r\n to separate headers, although some Unix mail transfer agents replace \n by \r\n automatically (leads to doubling \r if \r\n is used). Example 2. Sending mail with extra headers. The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option. You may need to add the user that your web server runs as to your sendmail configuration to prevent a 'X-Warning' header from being added to the message when you set the envelope sender using this method. Example 3. Sending mail with extra headers and setting an additional command line parameter. Note: This fifth parameter was added in PHP 4.0.5. Since PHP 4.2.3 this parameter is disabled in safe_mode and the mail() function will expose a warning message and return FALSE if you're trying to use it. You can also use simple string building techniques to build complex email messages. Example 4. Sending complex email.

Here are the birthdays upcoming in August!
Person Day Month Year Joe 3rd August 1970 Sally 17th August 1973
';/* To send HTML mail, you can set the Content-type header.
*/$headers  = "MIME-Version: 1.0\r\n";$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";/* additional headers */$headers .= "To: Mary , Kelly \r\n";$headers .= "From: Birthday Reminder \r\n";$headers .= "Cc: birthdayarchive@example.com\r\n";$headers .= "Bcc: birthdaycheck@example.com\r\n";/* and now mail it */mail($to, $subject, $message, $headers);?>
Note: Make sure you do not have any newline characters in the to or subject, or the mail may not be sent properly. Note: The to parameter should not be an address in the form of "Something ". The mail command may not parse this properly while talking with the MTA (Particularly under Windows). ========================================

#2 h3lium

h3lium

    Newbie [ Level 2 ]

  • Members
  • 10 posts

Posted 10 August 2005 - 07:11 PM

awesome. i didn't think you could send mail with php.

#3 Houdini

Houdini

    Super Member

  • Members
  • 572 posts
  • Location:Nashville Tennessee

Posted 30 March 2006 - 10:30 PM

Nearly the entire tutorial can be found here at this PHP Manual page and actually almost verbatim the HTML in Email example if right from the manual. To learn even more then I sould suggest that you download the manual and possibly also get a great free PHP editor like PHP Designer and it will incorperate the manual and do keyword lookup of PHP functions like the PHP mail() and you would learn even more if you use the online book at this link Practical PHP you might even learn more, it is full of examples and covers just about everything including PHP 5 with the support for OOP.

#4 Guest_(G)_*

Guest_(G)_*
  • Guests

Posted 26 November 2009 - 06:02 PM

it not working for me even though I modified php.Ini file like this

[mail function]; For Win32 only.;smtp = localhostSmtp_port=25; For Win32 only.;sendmail_from = xxxxxxx@rocketmail.Com

I don't no what to do other then is...Pls help me this could me v usefull for my project



#5 Guest_(G)kalaivanan_*

Guest_(G)kalaivanan_*
  • Guests

Posted 30 December 2009 - 07:27 AM

Modify php.Ini file like this

[mail function]; For Win32 only.Smtp = smpt.Gmail.Com

Smtp_port=465; For Win32 only.Sendmail_from = xxxxxxx@gmail.Com

sendmail_path='Cxampsendmail...'

I think it will work

-reply by kalaivanan

#6 Guest_(G)rabin_*

Guest_(G)rabin_*
  • Guests

Posted 24 February 2010 - 12:16 PM

it doesent work for other address for e.G brajesh@hostinnepal.Com

-reply by rabin

#7 Guest_(G)pankaj_*

Guest_(G)pankaj_*
  • Guests

Posted 30 September 2010 - 12:38 PM

what mail function return on success. what is the vale of $response variable when mail successfully sent.Sending Mail Using PHP's Mail() Function

        $to = "info@vaidrishi.Com";      $from = "info@vaidrishi.Com";      $subject = "Enquiry Details";      $headers  = "From: $fromrand";   $headers .= "Content-type: text/htmlrand";      $message = "<b>Name</b> : ". $_POST['askname'] . "<br><b>Mob No</b> : " . $_POST['askmob'] ."<br><b>Email</b>:".$_POST['askemail']."<br><b>Message</b>:".$_POST['askmessage'];            $response=@mail($to,$subject,$message,$headers);

-question by pankaj

#8 Guest_algo160_*

Guest_algo160_*
  • Guests

Posted 09 December 2011 - 12:48 AM

can you read mail with php?

#9 Guest_Le Béret Gascon_*

Guest_Le Béret Gascon_*
  • Guests

Posted 03 August 2012 - 05:57 PM

can you read mail with php?


http://www.horde.org/ (amongst others)



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users