{"id":384,"date":"2019-08-21T16:41:20","date_gmt":"2019-08-21T15:41:20","guid":{"rendered":"https:\/\/blogs.gre.ac.uk\/cmssupport\/?page_id=384"},"modified":"2019-08-21T16:41:20","modified_gmt":"2019-08-21T15:41:20","slug":"sending-email-using-php","status":"publish","type":"page","link":"https:\/\/blogs.gre.ac.uk\/cmssupport\/application-development\/programming\/php\/sending-email-using-php\/","title":{"rendered":"Sending email using PHP"},"content":{"rendered":"\n<p>Any script creating excessive mail error messages is likely to be disabled.<br><br>WARNING: Any inappropriate use of University email facilities will result in your account being disabled.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">On the stuiis.cms.gre.ac.uk server<\/h2>\n\n\n\n<p>To send an email through PHP on stuiis.cms.gre.ac.uk you need to add the following line to your code before using the&nbsp;mail()&nbsp;function:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ini_set(\"sendmail_from\",\"username@gre.ac.uk\");<\/pre>\n\n\n\n<p>Replace&nbsp;username&nbsp;with your user ID (e.g. cl697)<br><br>You can then use the&nbsp;mail()&nbsp;function to send your email:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mail(\"anotheruser@gre.ac.uk\", \"email title\", \"email message\");<\/pre>\n\n\n\n<p>Alternatively you can specify the &#8216;From&#8217; address in the&nbsp;mail()&nbsp;command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mail( $t_email, $subject, $message, \"From: username@gre.ac.uk\\r\\n\");<\/pre>\n\n\n\n<p>Replace&nbsp;username&nbsp;with your user ID (e.g. cl697)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">On the stuweb.cms.gre.ac.uk server<\/h2>\n\n\n\n<p>To send an email through PHP on stuweb.cms.gre.ac.uk you need to use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mail(\"[TO_ADDRESS]\", \"[SUBJECT]\", \"[MESSAGE]\", \"From: [USERID]@gre.ac.uk\\r\\n\");<\/pre>\n\n\n\n<p>To send an email through PHP on stuweb.cms.gre.ac.uk you need to use the following command:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Replace&nbsp;[TO_ADDRESS]&nbsp;with the email address that you wish to send the email to<\/li><li>Replace&nbsp;[SUBJECT]&nbsp;with the email&#8217;s subject (summarising the contents of the email)<\/li><li>Replace&nbsp;[MESSAGE]&nbsp;with the main content that you wish to send (i.e. your message)<\/li><li>Replace&nbsp;[USERID]&nbsp;with your user ID (e.g. cl697)<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Any script creating excessive mail error messages is likely to be disabled. WARNING: Any inappropriate use of University email facilities will result in your account being disabled. On the stuiis.cms.gre.ac.uk server To send an email &hellip;<\/p>\n","protected":false},"author":53,"featured_media":0,"parent":122,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-384","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages\/384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/users\/53"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/comments?post=384"}],"version-history":[{"count":0,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages\/384\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/pages\/122"}],"wp:attachment":[{"href":"https:\/\/blogs.gre.ac.uk\/cmssupport\/wp-json\/wp\/v2\/media?parent=384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}