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:").

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.

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

$title='mail test';
$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";


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></blockquote> <p>To learn more about Perl, visit the <a class="bb-url" href="" target="_blank"> web site</a>, purchase a <a class="bb-url" href=";_ylt=AnMd2eLEExn4xLGkoz_wv.obFt0A?p=Perl&did=7" target="_blank">book about Perl</a>, or review <a class="bb-url" href="" target="_blank">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="" target="_blank">PHP Group web site</a> or getting a <a class="bb-url" href=";_ylt=AnMd2eLEExn4xLGkoz_wv.obFt0A?p=php&did=7" target="_blank">book on PHP</a>. It may also be helpful to review other <a class="bb-url" href="" 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 "> <a href="" data-ylk="t3:top-links;t8:How do I send email with Perl or PHP?;t9:SLN20642;t4:Yahoo Password Helper||0;">Yahoo Password Helper</a> </div> <div class="row last-row"> <a href="" data-ylk="t3:top-links;t8:How do I send email with Perl or PHP?;t9:SLN20642;t4:Report Abuse||0;">Report Abuse</a> </div> </div> </div> <div class="container-menu-box"> <div class=" header-menu-box"> <a href="" data-ylk="t3:Contact Us;t8:How do I send email with Perl or PHP?;t9:SLN20642;t4:Contact Us||2;">Contact Us</a> </div> </div> </div> <!-- footer --> <footer class="ft out-links" id="ft" > <p> <a id='privacy' href="">Privacy</a> <b> | </b> <a id='terms' href="">Terms</a> </p> </footer> <!-- footer --> </div> </div> <script type="text/javascript" charset="utf-8" src=""></script> <script type="text/javascript" src=""></script> <script> YUI.applyConfig({ root:'yui:3.17.2/build/', allowRollup: true, combine: true, comboBase: '', maxURLLength: 2000, groups: { gallery: { root: 'yui:gallery-2014.04.02-20-01/build/', combine: true, base: '', comboBase: '', 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="" 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=''></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: '', pst : "desktop", articleDocId : "SLN20642", }; </script> <script src="" type="text/javascript"></script> </body> </html>