Search Help

How do I send email with Perl or PHP?

Before you can send email with Perl or PHP, you must complete the PHP/Perl Mail Setup process. 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

The mail setup process allows you to customize the email address that users will see when you send them a message (for example, "From: siteowner@widgetdesigns.com").

You will also 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.

Please note that you will be limited to 250 emails per day to recipients outside your domain. The "From:" address used in your script must also contain your domain name. If the "From:" field is omitted, your default account email address will be used.

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

Note: Notice that the subject line in the sample script below ends with two \n characters. These characters are required to separate the email header from the email body with a blank line. If you are not seeing the body of your email, be sure to double-check that 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>";<br/></p></blockquote><p>To learn more about Perl, visit the <a href="http://www.perl.com/" class="bb-url" target="_blank">Perl.com web site</a>, purchase a <a href="http://shopping.yahoo.com/search;_ylt=AnMd2eLEExn4xLGkoz_wv.obFt0A?p=Perl&did=7" class="bb-url" target="_blank">book about Perl</a>, or review <a href="http://dir.yahoo.com/Computers_and_Internet/Programming_and_Development/Languages/Perl/" class="bb-url" target="_blank">other Perl resources</a>.</p><p>To learn more about how to send email with PHP, we suggest researching the <a href="http://www.php.net/" class="bb-url" target="_blank">PHP Group web site</a> or getting a <a href="http://shopping.yahoo.com/search;_ylt=AnMd2eLEExn4xLGkoz_wv.obFt0A?p=php&did=7" class="bb-url" target="_blank">book on PHP</a>. It may also be helpful to review other <a href="http://dir.yahoo.com/Computers_and_Internet/Software/Internet/World_Wide_Web/Servers/Server_Side_Scripting/PHP/" class="bb-url" target="_blank">PHP resources</a>.</p> </div> <div class="box-item" id="fbkdp" data-ylk="t1:a2;t2:body;t3:articleFeedback;t8:How do I send email with Perl or PHP?;t9:SLN20642;"> <div id="qhelpfuld" class="feedback-div"> <div> Was this article helpful? <button id="helpfuld">Yes</button> <button id="nohelpfuld">No</button> </div> </div> <p class="thanks ico-check"> <span>Thank you! Your feedback has successfully been submitted.</span> </p> <div class="no-feedback"> <p><b>Please tell us why you didn't find this helpful.</b></p> <form action="" method="POST"> <p> <input type="radio" checked="" class="radio-btn" value="Article.Feedback.Unclear" name="reason" id="btn1"> <span class="cust-radio-btn"></span> <label>Unclear or complicated information</label> </p> <p> <input type="radio" class="radio-btn" value="Article.Feedback.Incorrect" name="reason" id="btn2"> <span class="cust-radio-btn"></span> <label>Incorrect information</label> </p> <p> <input type="radio" class="radio-btn" value="Article.Feedback.DoesNotAddress" name="reason" id="btn3"> <span class="cust-radio-btn"></span> <label>Article not addressing my issue</label> </p> <p> <input type="radio" class="radio-btn" value="Article.Feedback.TooLong" name="reason" id="btn4"> <span class="cust-radio-btn"></span> <label>Article too long</label> </p> <p> <input type="radio" class="radio-btn other" value="Article.Feedback.Other" name="reason" id="btn5"> <span class="cust-radio-btn"></span> <label>Other</label> </p> <p> <textarea placeholder="Please tell us why you didn't find this helpful." name="other" id="other_explain"></textarea> </p> <p> <span class="btn btn-regular" id="submit">Send Feedback</span> </p> </form> </div> </div> </div> <div class="col-2" id="right_portlets" data-ylk="t1:a3;t2:sidebar;"> <!-- Related articles portlet --> <!-- Related articles portlet ends --> <div class="container-menu-box"> <div class=" header-menu-box"> <a href="#" data-ylk="t3:Top Links;t8:How do I send email with Perl or PHP?;t9:SLN20642;t4:Top Links|null|1;">Top Links</a> </div> <!-- <div class="body-menu-box"> <div class="row last-row no-hover"> <p class="title-last-box"><b>Meet the multi-talented Yahoo Mail app.</b></p> <div class="app-showcase"> <img src="imgs/mobile.png" alt="mobile" /> <p>Check your mail, personalized news , local weather, sports scores, stocksand more – all from one app</p> <p><a href="#app" class="btn-app"><img src="imgs/btn.png" alt="button"/></a></p> </div> </div> </div>--> <div class="body-menu-box"> <div class="row "> <a href="https://edit.yahoo.com/forgotroot/" data-ylk="t3:top-links;t8:How do I send email with Perl or PHP?;t9:SLN20642;t4:Yahoo Password Helper|https%3A%2F%2Fedit.yahoo.com%2Fforgotroot%2F|0;">Yahoo Password Helper</a> </div> <div class="row last-row"> <a href="http://help.yahoo.com/l/us/yahoo/smallbusiness/abuse.html" data-ylk="t3:top-links;t8:How do I send email with Perl or PHP?;t9:SLN20642;t4:Report Abuse|http%3A%2F%2Fhelp.yahoo.com%2Fl%2Fus%2Fyahoo%2Fsmallbusiness%2Fabuse.html|0;">Report Abuse</a> </div> </div> </div> <div class="container-menu-box"> <div class=" header-menu-box"> <a href="https://smallbusiness.yahoo.com/contact" data-ylk="t3:Contact Us;t8:How do I send email with Perl or PHP?;t9:SLN20642;t4:Contact Us|https%3A%2F%2Fsmallbusiness.yahoo.com%2Fcontact|2;">Contact Us</a> </div> <!-- <div class="body-menu-box"> <div class="row last-row no-hover"> <p class="title-last-box"><b>Meet the multi-talented Yahoo Mail app.</b></p> <div class="app-showcase"> <img src="imgs/mobile.png" alt="mobile" /> <p>Check your mail, personalized news , local weather, sports scores, stocksand more – all from one app</p> <p><a href="#app" class="btn-app"><img src="imgs/btn.png" alt="button"/></a></p> </div> </div> </div>--> </div> </div> <!-- footer --> <footer class="ft out-links" id="ft" > <p> <a id='privacy' href="https://info.yahoo.com/privacy/us/yahoo/">Privacy</a> <b> | </b> <a id='terms' href="https://info.yahoo.com/legal/us/yahoo/utos/en-us">Terms</a> </p> </footer> <!-- footer --> </div> </div> <script type="text/javascript" charset="utf-8" src="https://s.yimg.com/zz/combo?yui:3.17.2/build/yui/yui-min.js"></script> <script type="text/javascript" src="https://s.yimg.com/zz/combo?yui:3.17.2/build/yui/yui-min.js"></script> <script> YUI.applyConfig({ root:'yui:3.17.2/build/', allowRollup: true, combine: true, comboBase: 'https://s.yimg.com/zz/combo?', maxURLLength: 2000, groups: { gallery: { root: 'yui:gallery-2014.04.02-20-01/build/', combine: true, base: 'https://s.yimg.com/zz/combo?', comboBase: 'https://s.yimg.com/zz/combo?', patterns: { 'gallery-': {} } } } }); </script> <script> var s = false, ts,re2,sdts,v2= null, cookies = "; " + document.cookie, dss = cookies.split("; DSS="), m, ua = window.navigator.userAgent.toLowerCase(); m = ua.match(/firefox\/(\d+)/); if (!m || (m && m[1] && parseInt(m[1]) < 34)) { if (ua.indexOf('version') >= 0 && ua.indexOf('crios') < 0) { s = true; } if (!!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) { s = true; } if (dss && dss.length === 2) { re2 = new RegExp('sdts=(\\d+)'); v2 = re2.exec(dss[1]); if (v2 && v2.length === 2) { sdts = v2[1]; } if (sdts && (parseInt(new Date().getTime()) - sdts) < 604800000) { s = true; } } if (!s) { m = document.getElementById('yucs-top-ff-promo'); m.className = m.className.replace(/D-n/g,''); } }</script> <script charset="utf-8" type="text/javascript" src="https://s.yimg.com/zz/combo?kx/yucs/uh3s/uh/280/js/scroll-handler-min.js" async></script> <script type="text/javascript" charset="utf-8"> YUI().use('node','node-focusmanager','base','io','json','async-queue','cookie','event-custom','jsonp','jsonp-url','node','event','substitute','cookie','event-resize','node','event','base','event-resize','event-hover','node-focusmanager','event-mouseenter','event-delegate','node','oop','dom-screen','oop','node','event-custom','cookie','substitute','classnamemanager','querystring-stringify', function(Y) {});</script> <script charset='utf-8' type='text/javascript' src='https://s.yimg.com/zz/combo?kx/yucs/uh3s/uh/224/js/uh-min.js&kx/yucs/uh3s/uh/57/js/persistence-min.js&kx/yucs/uh3s/uh/336/js/menu_group_plugin-min.js&kx/yucs/uh3s/uh/326/js/menu-plugin-min.js&kx/yucs/uh3s/uh/330/js/menu_handler_v2-min.js&kx/yucs/uh3s/uh/8/js/gallery-jsonp-min.js&kx/yucs/uh3s/uh/251/js/logo_debug-min.js&kx/yucs/uh3/uh/js/958/localeDateFormat-min.js&kx/yucs/uh3s/uh/74/js/timestamp_library-min.js&kx/yucs/uh3s/uh/241/js/usermenu_v2-min.js&kx/yucs/uh3/signout-link/10/js/signout-min.js&kx/yucs/uhc/meta/55/js/meta-min.js&kx/yucs/uh_common/beacon/18/js/beacon-min.js&kx/yucs/uh2/comet/84/js/cometd-yui3-min.js&kx/yucs/uh2/comet/84/js/conn-min.js&kx/yucs/uh2/comet/84/js/dark-test-min.js&kx/yucs/uh3/disclaimer/374/js/disclaimer_seed-min.js&kx/yucs/uh3s/top_bar/11/js/top_bar_v2-min.js&kx/yucs/uh3s/top-bar/27/js/home_menu-min.js&kx/yucs/uh3s/search/248/js/search-min.js&kx/yucs/uh3s/help/53/js/help_menu_v4-min.js'></script> <script type="text/javascript"> var rapidConf = { spaceid : "1182477573", locale : "en-US", product : "PROD_YSB", version : "PROD_YSB_WH", country : "US", inquira : "inquira", ab_bucket : "B", ywa_projectid : "1000379873063", page_type : "4", page_name : "Yahoo Web Hosting | - SLN20642 - How do I send email with Perl or PHP?", tracked_mods : {"bcd": "article-breadcrumbs", "article_container": "article-body", "right_portlets": "article-sidebar", "artAlert": "article-alert", "artAnnounce": "article-announcement"}, usm_sample_id : "help_hic3_test_bucket_B", ywa_region : "AMER", partner : document.getElementById("partner-div").getAttribute("partner-name"), link3pas : "null", link3pa : "null", decriid : "", webworker_file: 'https://help.yahoo.com/kb/rapidworker-1.1.js', pst : "desktop", articleDocId : "SLN20642", }; </script> <script src="https://s.yimg.com/zz/combo?ss/rapid-3.17.1.js&pj/contact/201501202230/resource/js/help_rapid.js&pj/contact/201501202230/resource/js/survey.js&pj/contact/201501202230/resource/js/article.js" type="text/javascript"></script> </body> </html>