How can I send email with PHP?

Before you can send email with Perl or PHP, you'll need to complete the PHP/Perl Mail Setup.

To begin setting up PHP/Perl mail, click the PHP/Perl Mail link on the Create & Update or Index tabs of your Web Hosting Control Panel.

 

Create and Update Tab: PHP/Perl Mail Link
Create & Update Tab: PHP/Perl Mail Link

 

  • You can customize the email address that users will see when you send them a message (for example, "From: siteowner@widgetdesigns.com").
  • You will need to indicate the path to the Yahoo mail program, Sendmail, in the Perl or PHP script. The path to Sendmail is /usr/sbin/sendmail.
  • There is a limit of 250 emails per day sent to recipients outside your domain.
  • The "From:" address used in your script must contain your domain name.
  • If the "From:" field is omitted, your default account email address will be used.

 

Here is a sample Perl script you can use to send email. You will need to specify the "to" and "from" address.

Notice that the subject line in the sample script ends with two \n characters. These characters are required to separate the email header from the email body with a blank line. If you're not seeing the body of your email, double-check to make sure these characters are present.

#!/usr/bin/perl

print "Content-type: text/html\n\n";

$title='mail test';
$to='MAIL ADDRESS TO SEND TO';
$from= 'EMAIL@YOURDOMAIN.COM';
$subject='Using Sendmail';

open(MAIL, "|/usr/sbin/sendmail -t");

## Mail Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
## Mail Body
print MAIL "This is a test message from Yahoo \n";

close(MAIL);

print "$title<<br /> /title></head>\n<body>\n\n";</p> <p>## START HTML content<br /> print "<h1>$title</h1>\n";<br /> print "<p>A message has been sent from $from to $to";<br /> ## END HTML CONTENT<br /> print "\n\n</body></html>";</p> <p> </p> </blockquote> <p>To learn more about Perl, visit the <a class="bb-url" href="http://www.perl.com/">Perl.com web site</a>, purchase a <a class="bb-url" href="http://shopping.yahoo.com/search;_ylt=AnMd2eLEExn4xLGkoz_wv.obFt0A?p=Perl&did=7">book about Perl</a>, or review <a class="bb-url" href="http://dir.yahoo.com/Computers_and_Internet/Programming_and_Development/Languages/Perl/">other Perl resources</a>.</p> <p>To learn more about how to send email with PHP, we suggest researching the <a class="bb-url" href="http://www.php.net/">PHP Group web site</a> or getting a <a class="bb-url" href="http://shopping.yahoo.com/search;_ylt=AnMd2eLEExn4xLGkoz_wv.obFt0A?p=php&did=7">book on PHP</a>. It may also be helpful to review other <a class="bb-url" href="http://dir.yahoo.com/Computers_and_Internet/Software/Internet/World_Wide_Web/Servers/Server_Side_Scripting/PHP/">PHP resources</a>.</p> </div> <article> <div class="rat" id="rating"> <ul> <li class="hlp"><p>Was this article helpful?</p></li> <li class="yes"><a href="#aYes" name="aYes" class="y" id='aYes'><b></b>Yes</a> </li> <li class="no"><a href="#aNo" name="aNo" class="n" id='aNo'><b></b>No</a> </li> </ul> </div> <a name="Article.Feedback.Unclear"></a> <a name="Article.Feedback.Incorrect"></a> <a name="Article.Feedback.DoesNotAddress"></a> <a name="Article.Feedback.TooLong"></a> <a name="Article.Feedback.Other"></a><p id="thankyou" class="aty" style="display:none;"><b></b>Thanks for your feedback.</p> </article> </div> </article> <p class="snh">Still need help?</p> <div class="mnu ccu" id="f5"> <ul class="cti"> <li><a href="contact.php"><div>Contact Customer Care</div> <span><em></em> </span> </a></li> </ul> </div> <!-- ============ END MENU ============ --> </div> </div> <!-- ============ END CONTENT BODY ============ --> <div></div> <div id="feedbackNo" style="display:none"> <a href="#" id="close"><img alt="cloase" border="0" src="https://s.yimg.com/pj/mobile/images/close_8710.jpg" /> </a> <div id="feedcontent"> <p class='qs'>Quick Survey</p> <p class='fh'>Tell us why this article was not helpful?</p> <ul id="ful"> <li> <div class="rimg"> <a id="radio1" href="#Article.Feedback.Unclear" class="radio"> <img src="https://s.yimg.com/pj/mobile/images/radio_8710.png" alt="Article.Feedback.Unclear" border="0" /> </a> </div> <div>Unclear or complicated information</div> </li> <li> <div class="rimg"><a id="radio2" href="#Article.Feedback.Incorrect" class="radio"> <img src="https://s.yimg.com/pj/mobile/images/radio_8710.png" alt="Article.Feedback.Incorrect" border="0" /> </a> </div> <div>Incorrect information</div> </li> <li> <div class="rimg"> <a id="radio3" href="#Article.Feedback.DoesNotAddress" class="radio"> <img src="https://s.yimg.com/pj/mobile/images/radio_8710.png" alt="Article.Feedback.DoesNotAddress" border="0" /> </a> </div> <div>Article not addressing my issue</div> </li> <li> <div class="rimg"><a id="radio4" href="#Article.Feedback.TooLong" class="radio"> <img src="https://s.yimg.com/pj/mobile/images/radio_8710.png" alt="Article.Feedback.TooLong" border="0" /> </a> </div> <div>Article too long</div> </li> <li> <div class="rimg"> <a id="radio5" href="#Article.Feedback.Other" class="radio"> <img src="https://s.yimg.com/pj/mobile/images/radio_8710.png" alt="Article.Feedback.Other" border="0" /> </a> </div> <div>Other</div> </li> </ul> <div id='fdiv'> <a href="#" id="feedbacksubmitlink" data-ylk=""> <img alt="" id="feedbackSubmit" src="https://s.yimg.com/pj/mobile/images/ok_8710.jpg" border="0" /> </a> </div> </div> <!-- ============ END PAGE BODY ============ --> </div> </div> </div> </div> </div> <script type='text/javascript' src='https://yui-s.yahooapis.com/combo?2.9.0/build/yahoo-dom-event/yahoo-dom-event.js&2.9.0/build/element/element-min.js&2.9.0/build/tabview/tabview-min.js'></script><script type='text/javascript' src='https://yui-s.yahooapis.com/combo?3.10.0/build/yui/yui-min.js'></script><script type='text/javascript' src='https://s.yimg.com/zz/combo?pj/mobile/js/mobile-min_18338.js' ></script><script type='text/javascript' src='https://s.yimg.com/ss/rapid-3.4.5.js' ></script><script charset='utf-8' type='text/javascript' src='https://s.yimg.com/zz/combo?kx/yucs/uh3/uh/1061/js/uh_mobile-min.js&kx/yucs/uhc/meta/16/js/meta-min.js&kx/yucs/uh_common/beacon/18/js/beacon-min.js&kx/ucs/comet/js/77/cometd-yui3-min.js&kx/ucs/comet/js/77/conn-min.js&kx/ucs/comet/js/77/dark-test-min.js&kx/yucs/uh3/disclaimer/191/js/disclaimer_seed-min.js&kx/yucs/uh3/search/591/js/search_mobile-min.js&kx/yucs/uhc/rapid/23/js/uh_rapid-min.js&kx/yucs/uh3/uh/1061/js/uh_mobile-min.js&kx/yucs/uh3/sidebar/318/js/sidebar-debug-min.js&kx/yucs/uh3/navigation/149/js/navigation_mobile_sidebar-min.js&kx/yucs/uh3/sidebar/js/279/sidebar_utils-min.js '> </script><script type='text/javascript' charset='utf-8'> YUI().use( 'widget','event-gestures','node','querystring-stringify','jsonp','cache' , function(Y) {});</script><script type='text/javascript' charset='utf-8'> YUI().use( 'node','autocomplete','escape','base','io','json','async-queue','cookie','event-custom','node','event','substitute','cookie','event-resize','node', 'autocomplete', 'autocomplete-highlighters' , function(Y) {});</script> <script type='text/javascript'> YAHOO.i13n.YWA_CF_MAP = { thumb_down_reason:17, ywaclick:26}; YAHOO.i13n.YWA_ACTION_MAP = {'SALE':1,'SEND_MAIL_BUTTON':3,'Ask the Community':4,'THUMB_UP':5,'THUMB_DOWN':6,'CONTACT_US':7,'contact_yahoo_button':8,' cform-request-chat':9,'QL_watch_videos':10, 'ARTICLE_CLICK':11,'EMAIL_CLICK':12, 'Locked Accounts':13,' UPGRADE_TO_MESSENGER_CLICK':14, 'BREAD_CRUMBS_CLICK':15,'Yahoo! Customer Care on Facebook':16,'Show More Topics':17,' RATE_ARTICLE':18,' FEEBACK_BUTTON':19, 'THANK_YOU_CONVERSION':20, 'Yahoo! Customer Care on Twitter':21,' cform-rnchatstart':22, 'Show More Products':23, 'Chat Starts':24, ' Chat Interactive':25,'Article_SendFeedback_Button':26, 'cform-request-email':27, 'cform-emailsend':28,' thank_you_conversion_INQ':29, 'Contact Customer Care':30,' cform-selectprod':31, 'cform-selectsubprod':32,' cform-selectcat':33,' cform-selectsubcat':34,'cform-issuedesc-enterbutton':35, 'cform-request-p2p':36, 'cform-sendtop2p':37, 'Community Topic Star Rating':38, 'Community Reply Star Rating':39, 'Portlet Click':40, ' video-play-embedded':41, 'cform-promo banner click':42, 'cform-search option':43,'cform-phone submission':44,' cform-deflection article displayed':45, 'sign_in_button':46,'Start Password Helper': 47,'Community article click (unique) ':49,'cform-request-phone':50, 'Locked_Acct_Help':51 };var keys = {A_id:'rapid_id', A_pt:'Yahoo Web Hosting Help | How can I send email with PHP?', A_pn:'Yahoo Web Hosting Help | How can I send email with PHP?'}; var conf = {lt_attr:"text", track_pv:true, client_only:1, keys:keys, spaceid:'1182477569',ywa:{ cf:{7:"1182477569", '4':'mobile_help','2':'en_US','8':''}, project_id:"1000379873063"}}; var ins = new YAHOO.i13n.Rapid(conf); function fireFeedback( actionName, cfField){ var keys1 = {A_id:'rapid_id', A_pt:'Yahoo Web Hosting Help | How can I send email with PHP?', A_pn:'Yahoo Web Hosting Help | How can I send email with PHP?'}; var conf1 = { lt_attr:"text", track_pv:true, client_only:1, keys:keys1, spaceid:'1182477569',ywa:{ cf:{7:"1182477569", '4':'mobile_help','2':'en_US','8':'','17':cfField}, project_id:"1000379873063"}}; var ins1 = new YAHOO.i13n.Rapid(conf1); ins1.beaconEvent( actionName, {}, 'yes'); } function fireBeaconEvent( actionName ) { ins.beaconEvent( actionName, {}, 'yes'); } </script> <script type="text/javascript"> YUI().use('node', 'io', 'event', 'animation','node-load', function (Y) { Y.one('#feedbackNo').hide(); Y.all('.art .bd img').each( function() { var width = this.get('offsetWidth'); if(width > 240) { this.wrap("<p></p>"); this.wrap("<div class='tbl'></div>"); var div=this.get('parentNode'); var p=div.get('parentNode'); var html=div.get('parentNode.innerHTML'); p.setContent("<p class='arw'><b></b> Slide left to see more</p>"+html); } }); Y.one('.yes a').on('click',function(e){ fireBeaconEvent('THUMB_UP'); Y.one('#rating').hide(); Y.one('#thankyou').show(); e.preventDefault(); }); var node=Y.one('#feedbacksubmitlink'); Y.one('#aNo').on('click',function(e){ fireBeaconEvent('THUMB_DOWN'); Y.one('#feedbackNo').show(); window.scrollTo(0,0); /* Y.one('#rdiv').hide(); Y.one('body').addClass('bgcolor'); */ e.preventDefault(); }); Y.one('#feedbacksubmitlink img').on('click',function(e){ Y.one('#feedbackNo').hide(); var feedVal=node.getAttribute("href"); var feedValue=feedVal.replace("#",""); fireFeedback('Article_SendFeedback_Button',feedValue); /*Y.one('#rdiv').show(); Y.one('body').removeClass('bgcolor'); */ Y.one('#rating').hide(); Y.one('#thankyou').show(); window.history.back(); }); Y.one('#close').on('click',function(e){ Y.one('#feedbackNo').hide(); Y.one('#rdiv').show(); Y.one('body').removeClass('bgcolor'); e.preventDefault(); }); Y.one('#radio1 img').on('click',function(e) { Y.all('#ful img').each(function (e) { this.setAttribute("src","https://s.yimg.com/pj/mobile/images/radio_8710.png"); }); node.setAttribute("href","#"+this.getAttribute("alt")); node.setAttribute("data-ylk","thumb_down_reason:"+this.getAttribute("alt")+";"); this.setAttribute("src","https://s.yimg.com/pj/mobile/images/cradio_8710.png"); e.preventDefault(); }); Y.one('#radio2 img').on('click',function(e) { Y.all('#ful img').each(function (e) { this.setAttribute("src","https://s.yimg.com/pj/mobile/images/radio_8710.png"); }); node.setAttribute("href","#"+this.getAttribute("alt")); node.setAttribute("data-ylk","thumb_down_reason:"+this.getAttribute("alt")+";"); this.setAttribute("src","https://s.yimg.com/pj/mobile/images/cradio_8710.png"); e.preventDefault(); }); Y.one('#radio3 img').on('click',function(e) { Y.all('#ful img').each(function (e) { this.setAttribute("src","https://s.yimg.com/pj/mobile/images/radio_8710.png"); }); node.setAttribute("href","#"+this.getAttribute("alt")); node.setAttribute("data-ylk","thumb_down_reason:"+this.getAttribute("alt")+";"); this.setAttribute("src","https://s.yimg.com/pj/mobile/images/cradio_8710.png"); e.preventDefault(); }); Y.one('#radio4 img').on('click',function(e) { Y.all('#ful img').each(function (e) { this.setAttribute("src","https://s.yimg.com/pj/mobile/images/radio_8710.png"); }); node.setAttribute("href","#"+this.getAttribute("alt")); node.setAttribute("data-ylk","thumb_down_reason:"+this.getAttribute("alt")+";"); this.setAttribute("src","https://s.yimg.com/pj/mobile/images/cradio_8710.png"); e.preventDefault(); }); Y.one('#radio5 img').on('click',function(e) { Y.all('#ful img').each(function (e) { this.setAttribute("src","https://s.yimg.com/pj/mobile/images/radio_8710.png"); }); node.setAttribute("data-ylk","thumb_down_reason:"+this.getAttribute("alt")+";"); node.setAttribute("href","#"+this.getAttribute("alt")); this.setAttribute("src","https://s.yimg.com/pj/mobile/images/cradio_8710.png"); e.preventDefault(); }); }); </script> </body> </html> <!-- extprodmob01.cc.gq1.yahoo.com Sat Jul 12 14:58:05 PST 2014 -->